in reply to Win file/dir names w/spaces
I then tried the File::Spec module. It helps.
Again, I was a bit surprised at the second case. But I can use one of the other two cases.$me = "dirtest3"; # Perl script to test variations on file/dir test argument quoting use File::Spec; print "All of the following conditions are true on my system.\n"; print "The issue is to see which tests work.\n"; print "The final path includes a directory name containing a space.\n" +; print "\n"; $part1 = "C:"; $part2 = "users"; $part3 = "public"; $part4 = "Music"; $part5 = "Sample Music"; $full = File::Spec->catfile( $part1, $part2, $part3, $part4, $part5 ); print "\nThese tests use a path consisting of concatenated substrings: +\n"; print " full = '$full'\n"; print "\n"; $expl = "Full path, unquoted"; if ( -e $full ) { print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n" +; } $expl = "Full path in single quotes"; if ( -e '$full' ) { print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n" +; } $expl = "Full path in double quotes"; if ( -e "$full" ) { print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n" +; }
All of the following conditions are true on my system. The issue is to see which tests work. The final path includes a directory name containing a space. These tests use a path consisting of concatenated substrings: full = 'C:\users\public\Music\Sample Music' '-e Full path, unquoted' is true '-e Full path in single quotes' is false '-e Full path in double quotes' is true
|
---|