SPUG: One-liners on Windows via command.com

Tim Maher tim at consultix-inc.com
Wed Mar 23 10:33:02 PST 2005

Can somebody give me pointers on how to modify Unix-ish one-liners
to work on Windows systems?

For example, this works on UNIX/Linux, because the single quotes (SQs)
are recognized as forming a literal string out of their contents, 
which gets passed as an argument to the command:

perl -wle 'print "Crikey";'	

On Win/XP, the same command elicits this Perl error:

C:\ perl -wle 'print "Crikey";'	
Can't find string terminator "'" anywhere before EOF at -e line 1.

I had expected some indication that command.com wouldn't know what
to do with the SQ, as opposed to an indication that Perl only got
a single one in -e's argument!  Can somebody explain what SQs do in
this shell?

On the other hand, I find that DQs as exterior quotes work fine
(on XP), and the backslash even appears to quote nested DQs, as
it does in the Unix shells:

C:\ perl -wle "print \"Crikey\";"	

and qq operator works:

C:\ perl -wle "print qq{Crikey};"	

as does the arguably more appropriate q operator:

C:\ perl -wle "print q{Crikey};"	

or the SQ itself:

C:\ perl -wle "print 'Crikey';"	

So now I'm wondering, do DQs in this shell allow any interpolations? 
If so, what Perl symbols would need to be quoted to suppress that?
Where does one get documentation on the workings of this shell?

"man perlport" provides lots of info on modifying Perl programs
/themselves/ for portability, but it has virtually nothing to say
on the subject of passing Perl code as a command-line argument.

Can somebody point me to their favorite tutorial covering the use
of command-line Perl techniques with Win32 systems?

| Tim Maher, PhD     (206) 781-UNIX      (866) DOC-PERL     (866) DOC-UNIX |
| tim(AT)Consultix-Inc.Com  http://TeachMePerl.Com  http://TeachMeUnix.Com |
|    Watch for my June, 2005 book: "Minimal Perl for UNIX/Linux People"    |

More information about the spug-list mailing list