6.2. Unit Testing

Perl shines at unit testing. Although there's no empirical data to prove this, conversational evidence suggests that most Perl programs are short enough that unit testing is the same as system testing. People often report that their programs shrink by 90% when converted from C to Perl (our experience bears this out). A 1000-line C program requires more heavy-duty testing than a 100-line Perl program.

6.2.1. The One-Liner

Although not strictly in the category of unit testing, we must mention the utility of the one-liner. Several flags in Perl make it possible for you to test an idiom without even having to write a script, but instead just entering the code on the command line. The first of these is:

  • -e code: Execute code as though ...

Get Perl Debugged now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.