[Buffalo-pm] one liner

Kevin Eye eye at buffalo.edu
Fri Jun 20 14:37:00 CDT 2003


> one of my favorite perl command line utilities:
>
> perl -de 0

Hang on there - that deserves far more than a passing mention. In fact, 
I'd go so far as to say that this tiny line, which lets one 
interactively enter and test code, is almost certainly the most 
under-appreciated feature of the language.

To clarify things, "perl -de 0" (aka. "perl -de0" or "perl -de 1") will 
invoke the perl debugger on the very short program "0" (or "1", or 
whatever). This alone is not very interesting, however, the perl 
debugger is a full-fledged interactive perl interpreter, evaluating 
anything you enter. It's extremely handy to test a couple lines of 
code, or see how a built-in function or module will handle a certain 
input. The debugger's "x" command is also very useful, as it will print 
out the contents of any complex data structure (e.g. an object, an 
array of hash refs, etc.).

Not being able to leave well-enough alone, I've actually turned this 
concept into an entire program I call "psh" (perl shell). It lets you 
enter commands interactively just like the debugger, and uses 
Data::Dumper to print the results. I can't live without it.

I'd love to demo this concept and program at a future meeting if 
there's time in our schedule. Let me know what you think.

  - Kevin


--
Kevin Eye
Web Applications Developer
Creative Services and Marketing
University at Buffalo
330 Crofts Hall
Buffalo, NY 14260
eye at buffalo.edu
phone (716) 645-5000 x1435
fax (716) 645-3765




More information about the Buffalo-pm mailing list