Can someone explain the difference between calling a perl script via file association versus calling the same script explicitly via perl.exe
?
Apparently I/O redirection doesn't work very well when the script is called via file association, and I would really like to know why.
E.g. take a look at the Activestate FAQ for Perl on Windows. The cat file
example works perfectly as long as the script doesn't receive its input via redirection. So
cat file.txt
works as expected, but
whoami | cat.pl
does not. Not only is the .pl
extension needed, but apparently the output of whoami
isn't piped into the script. The script is run (which can be verified by modifying the example cat.pl
script), but for some reason it doesn't receive the output of whoami
as input.
However, if I call the script like this:
whoami | perl cat.pl
everything works as expected.
So apparently there is an important difference between running the script via file association and explicitly calling perl.exe
with the script.
The FAQ mentions the problem and points out that using pl2bat
to generate a bat file cover for the script fixes the problem, but I don't understand why this is necessary.
Please enlighten me.