in reply to How do I open a file in a path that has spaces in the name?

Sorry for second post, but forgot to format >_<

Hi, I had the problem too but grinder gave me a hint:
" It depends on the environment" and in Windows/DOS, directories with spaces are between quotes
ex: c:\>dir "Program Files"

So, in windows, escape space chars like this: (supposing you have a "test" directory in c:\

$dir = "c:/test/\"Test Directory\"";
mkdir ($dir);
  • Comment on Re: How do I open a file in a path that has spaces in the name?

Replies are listed 'Best First'.
Re: Answer: How do I open a file in a path that has spaces in the name?
by Anonymous Monk on Nov 03, 2009 at 12:00 UTC
    1. Perlmonks FAQ
    2. grinder did not say
      $dir = "\"Test Directory\""; mkdir ($dir) or die "$!\n$^E"; __END__ Invalid argument The filename, directory name, or volume label syntax is incorrect at - + line 2.
    3. grinder said quote your arguments, eg C:\> perl program.pl "i got spaces and I end up in $ARGV[0]" or
      C:\> perl -le"print for @ARGV" "i got spaces and I end up in $ARGV[0]" + me too i got spaces and I end up in $ARGV[0] me too