I suggest you switch touse warnings;
to promote all warnings to errors and die immediately on the first warning (see Fatal Warnings).use warnings FATAL => 'all';
It is more effective at finding bugs in your code than plain old use warnings;.
It is a widely-regarded good Perl coding practice to add use warnings; to your code because you want perl to notify you of impending problems. In my experience, the warnings have always pointed to a bug in my code.
The issue is that, in some common usage scenarios, it is too easy to miss the warning messages unless you are looking for them. They can be hard to spot even if your code generates a small amount of output, not to mention anything that scrolls off the screen. Or, if your output (STDOUT and STDERR) is redirected to a log file which you typically do not look at, then you wouldn't see the warning messages. FATAL => 'all' will kill your program dead so that there is no way to miss the warnings. This is no different from use strict;, which dies immediately.
Although you may miss the warnings (without FATAL), there's a 100% chance your customers will see them. It's a little unprofessional looking if your code is spewing gobs of warning messages.
FATAL can also help prevent you from wasting your time if there are multiple warnings. Often times, the last warning is the most visible, but it's the first warning that you should target.
{ no warnings 'uninitialized'; # etc. }
use warnings ; # FATAL => 'all';
Updated: added direct link to fatal docs.
|
|---|