11. Warnings

Perl can be quite helpful in spotting suspicious code and letting you know about it. Most of the debugging skills you may have learned from other languages are just as applicable to Perl. When your program spits out pages and pages of warnings, start with the first ones.

There are several ways to enable warnings. Old-style Perl uses the -w switch on the command line:

image

You can also use command-line switches on the shebang line inside the program:

image

Modern Perl uses the warnings pragma inside the code (Item 99).

use warnings;

The trick ...

Get Effective Perl Programming: Ways to Write Better, More Idiomatic Perl, Second Edition 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.