Jeff wrote:
>
> I am using Active Perl under Windoze 98.  I am trying to open a file that has
> embedded spaces.  I tried escaping the spaces as well, and that didn't work
> either.
>
> #! perl -w
> $file = "c:\\win\\start menu\\programs\\system\\tbs montego\\_visit turtle beach web 
> site.lnk";
> print "file = $file\n";
> open(F, "< $file") or warn "cannot open $file (continuing): $!\n";
> $file =~ s/ /\\ /g;
> print "file = $file\n";
> open(F, "< $file") or die "cannot open $file: $!\n";
> close(F);
>
> produces:
>
> file = c:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk
> cannot open c:\win\start menu\programs\system\tbs montego\_visit turtle beach web 
> site.lnk (continuing): No such file or directory
> file = c:\win\start\ menu\programs\system\tbs\ montego\_visit\ turtle\ beach\ web\ 
> site.lnk
> cannot open c:\win\start\ menu\programs\system\tbs\ montego\_visit\ turtle\
> beach\ web\ site.lnk: No such file or directory
>
> The file _does_ exist and works fine if I use DOS 8.3 short names.
>
> Any suggestions?

Hi Jeff.

I agree with Tim, you've most likely got the filename slightly wrong. And
by the way it's a lot safer and more readable to use single quotes unless
you really need to interpolate variables or add control characters to a
string.

Try this short program so that you can see what Perl can see. It keeps shortening
the path until an opendir succeeds and then dumps the directory. Then you can cut
and paste the file names directly back into your code.

  use strict;
  use warnings;

  my $file = 'C:\win\start menu\programs\system\tbs montego\_visit turtle beach web 
site.lnk';

  my $dir = $file;
  my $dh;

  ($dir) = $dir =~ /(.+)\\/ or die until opendir $dh, $dir;

  print "dir = $dir\n";
  print map "$_\n", readdir $dh;

Just one thing: I presume your windows directory really is C:\win and not
C:\WINDOWS?

I hope this helps somehow,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to