I want to wrap a Perl one-liner in a batch file. For a (trivial) example, in a Unix shell, I could quote up a command like this:
perl -e 'print localtime() . '\n''
But DOS chokes on that with this helpful error message:
Can’t find string terminator ”’ anywhere before EOF at -e line 1.
What’s the best way to do this within a .bat file?
For Perl stuff on Windows, I try to use the generalized quoting as much as possible so I don’t get leaning toothpick syndrome. I save the quotes for the stuff that DOS needs:
If you just need a newline at the end of the print, you can let the
-lswitch do that for you:For other cool things you can do with switches, see the perlrun documentation.