Windows is weird.
These are the rules related to commands passed to the shell via cmd /C, which I believe how perl passes the command to the operating system.
M:\>help cmd
Starts a new instance of the Windows 2000 command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:
+OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminate
+s
/K Carries out the command specified by string but remains
/S Modifies the treatment of string after /C or /K (see below)
/Q Turns echo off
... deleted lines...
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic i
+s
used to process quote (") characters:
1. If all of the following conditions are met, then quote charact
+ers
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
the two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preservin
+g
any text after the last quote character.
I'm not quite sure why your original code worked
print STDERR "my echo.pl"
because it does not work for me. Possibly different flavours of Windows.
Anyways, my echo.pl is not an executable file, it is just that the file extension is associated with an executable.
try.pl
eval {print `my echo.pl`};
eval {print `"my echo.pl"`;};
eval {print `perl "my echo.pl"`};
eval {print `perl "my echo (v1).pl"`};
my echo.pl and my echo (v1).pl:
print "hello sandy\n";
Results "try.pl"
M:\>try.pl
Can't open perl script "M:\my": No such file or directory
Can't open perl script "M:\my": No such file or directory
hello sandy
hello sandy
Conclusion: Do not rely on Windows to resolve the file extionsions to determine the 'real' executable, but use the proper name (perl in this case). Quote the filename.
Hope that helps.