SPUG: One-liners on Windows via command.com

Marc M. Adkins Perl at Doorways.org
Wed Mar 23 09:59:43 PST 2005

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

This is the mode I use all the time.  I test lots of small Perl stuff 
from the command line ("gee, does this work the way I think it does?").

When I need to insert a carriage return I use:

	perl -e "print 'Path:  ', $_, chr(10) for @INC"

since '\n' doesn't do the right thing.

Seems like the '^' character will prevent characters from being glonged 
in the dreaded DOS box.  I don't find that I need to know that.

The thing I do use on occasion is the -x switch.  I can build a Perl 
script into a batch file.  Some DOS/Windows programs will execute a .bat 
file but not a Perl script.  The same with some people.  It's a nice bit 
of sleight-of-hand.

Yes, the old DOS command processor blows chunks.  I hold off from 
installing (?:ba|c|z)?sh or whatever because I've found in the past that 
customizing my environment overly much makes working with other people 
harder.  Leads to entropy in the cubicle space.  When I sit down to help 
someone I have to remember how to do things the hard way and end up 
muttering under my breath more than usual.  Not to mention having my 
weird scripts escape into the general code space, which always leads to 
screaming fits from the died-in-the-wool Windows programmers.  So I just 
suck it up.  I am, I suppose, a masochist.

Besides, I don't care how lame the command shell is.  I have Perl, which 
is better than any shell scripting language.


More information about the spug-list mailing list