I need to run the following command from inside a Perl script in Windows. The code can't be simpler than this:
#! C:\Perl\bin\perl
perl -e "print qq(Hello)";
I save this file as test.pl. I open a command prompt in Windows and run the following from the c:\Per\bin directory. When I run it as perl test.pl, I get the following result:
C:\Perl\bin>perl test.pl
syntax error at test.pl line 3, near ""perl -e "print"
Execution of test.pl aborted due to compilation errors.
How can I fix this? If I just run perl -e from the command prompt (i.e. without being inside the file) it works great.
perlis not a command that Perl knows. It also tells you this. What could you possibly do in an-ethat you can't do in a script?!?! The reason it runs great on the command line is that the OS considersperla "command" if it can find it in the PATH. Andperl -eis expected to "run great" from the command line--unlike in perl.