Perl pragma introduced in Perl 5.6 or so, to more or less replace the previously introduced -w command line switch.
warnings pragma is used very much like
strict pragma. Typically, you want to start the program like this, to avoid embarassing questions from Python zealots:
This will enable all warnings and only use proper style.
Warnings pragma is much more flexible than -w. You can disable warnings temporarily inside blocks with
no warnings; (certainly more readable than
local($^W)=0; and also works in compile phase!), and you can enable specific warnings with things like
use warnings qw(syntax utf8);. Also, you can make warnings fatal:
use warnings FATAL => qw(syntax); And that's not all! You can also make your own enablable/disablable warnings with it, using the stuff in
use warnings; is equivalent to
use warnings 'all';.
Here's a list of all warning categories, taken from perllexwarn perldoc of Perl 5.6.1: