$me = "dirtest1";
# Perl script to test variations on file/dir test argument quoting
print "All of the following conditions are true on my system.\n";
print "The issue is to see which tests work.\n";
print "The path includes a directory name containing a space.\n";
print "\n";
print "\nThese tests use a single, defined string as path:\n";
# This example would not run due to compiler errors
# $expl = "Bare unquoted text with single backslashes";
# if ( -e C:\users\public\Music\Sample Music )
# { print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n"; }
# This example would not run due to compiler errors
# $expl = "Bare unquoted text with double backslashes";
# if ( -e C:\\users\\public\\Music\\Sample Music )
# { print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n"; }
$expl = "Single-quoted text with single backslashes";
if ( -e 'C:\users\public\Music\Sample Music' )
{ print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n"; }
$expl = "Single-quoted text with double backslashes";
if ( -e 'C:\\users\\public\\Music\\Sample Music' )
{ print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n"; }
$expl = "Double-quoted text with double backslashes";
if ( -e "C:\\users\\public\\Music\\Sample Music" )
{ 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 path includes a directory name containing a space.
These tests use a single, defined string as path:
'-e Single-quoted text with single backslashes' is true
'-e Single-quoted text with double backslashes' is true
'-e Double-quoted text with double backslashes' is true
####
$me = "dirtest2";
# Perl script to test variations on file/dir test argument quoting
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:\\users\\public\\Music";
$part2 = "Sample Music";
$dfull = "$part1\\$part2";
print "\nThese tests use a path consisting of concatenated substrings:\n";
print " part1 = '$part1'\n";
print " part2 = '$part2'\n";
print " dfull = '$dfull'\n";
print "\n";
$expl = "Part1, unquoted";
if ( -e $part1 )
{ print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n"; }
$expl = "Full path, unquoted";
if ( -e $full )
{ print "'-e $expl' is true\n"; } else { print "'-e $expl' is false\n"; }
$expl = "Part1 in single quotes";
if ( -e '$part1' )
{ 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 = "Part1 in double quotes";
if ( -e "$part1" )
{ 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:
part1 = 'C:\users\public\Music'
part2 = 'Sample Music'
dfull = 'C:\users\public\Music\Sample Music'
'-e Part1, unquoted' is true
'-e Full path, unquoted' is false
'-e Part1 in single quotes' is false
'-e Full path in single quotes' is false
'-e Part1 in double quotes' is true
'-e Full path in double quotes' is false