Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jun 262010
 

Run Perl with useful warnings

Answer:

For good programming habits, it is advised to run Perl using the -w flag so it will print out some useful warnings that might be useful for your program.

E.g.

# perl -e 'print $foo';

The above script shows nothing, but with the -w flag,

# perl  -w -e 'print $foo'; 
Name "main::foo" used only once: possible typo at -e line 1.
Use of uninitialized value $foo in print at -e line 1.

So you can see it is very useful for debugging your program.

In fact, the -w flag is the same as the warnings pragma

use warnings;

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>