Rob Dixon <[EMAIL PROTECTED]> wrote: > 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,
The program worked, and returned a directory listing in that directory. Basically, the problem I am still having is that I have a list of LNK files that I want to open. So when I use this statement: open(F, "< $f") or die "cannot open file $f: $!\n"; the spaces get confused somehow. The 'win' directory is correct.... back in the days of Windows 3.1, disk space was a premium, so I applied a tip I read once to use 'win' instead of 'windows' to minimize disk space since "windows" was used in so many places. I am opening the LNK files to dump some information, specifically, what the short cut key is (Win32::Shortcut has some short falls). __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]