X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperllexwarn.pod;h=f250fb41ef5749c5e9e9225b57d1dd8be1a187aa;hb=cf2649810f00335bd657355d81bcc9384a620135;hp=b98e3332e4cccb537290573ec1317118e65737e1;hpb=13a2d996abe42696bc5ca08abf08030d440c6148;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perllexwarn.pod b/pod/perllexwarn.pod index b98e333..f250fb4 100644 --- a/pod/perllexwarn.pod +++ b/pod/perllexwarn.pod @@ -207,10 +207,12 @@ The current hierarchy is: all -+ | - +- chmod + +- assertions | +- closure | + +- deprecated + | +- exiting | +- glob @@ -221,6 +223,8 @@ The current hierarchy is: | | | +- exec | | + | +- layer + | | | +- newline | | | +- pipe @@ -265,8 +269,6 @@ The current hierarchy is: | | | +- bareword | | - | +- deprecated - | | | +- digit | | | +- parenthesis @@ -285,7 +287,7 @@ The current hierarchy is: | +- taint | - +- umask + +- threads | +- uninitialized | @@ -296,8 +298,6 @@ The current hierarchy is: +- utf8 | +- void - | - +- y2k Just like the "strict" pragma any of these categories can be combined @@ -316,6 +316,11 @@ C pragma in a given scope the cumulative effect is additive. To determine which category a specific warning has been assigned to see L. +Note: In Perl 5.6.1, the lexical warnings category "deprecated" was a +sub-category of the "syntax" category. It is now a top-level category +in its own right. + + =head2 Fatal Warnings The presence of the word "FATAL" in the category list will escalate any @@ -325,16 +330,16 @@ and C can all produce a C<"Useless use of xxx in void context"> warning. use warnings ; - + time ; - + { use warnings FATAL => qw(void) ; length "abc" ; } - + join "", 1,2,3 ; - + print "done\n" ; When run it produces this output @@ -346,6 +351,19 @@ The scope where C is used has escalated the C warnings category into a fatal error, so the program terminates immediately it encounters the warning. +To explicitly turn off a "FATAL" warning you just disable the warning +it is associated with. So, for example, to disable the "void" warning +in the example above, either of these will do the trick: + + no warnings qw(void); + no warnings FATAL => qw(void); + +If you want to downgrade a warning that has been escalated into a fatal +error back to a normal warning, you can use the "NONFATAL" keyword. For +example, the code below will promote all warnings into fatal errors, +except for those in the "syntax" category. + + use warnings FATAL => 'all', NONFATAL => 'syntax'; =head2 Reporting Warnings from a Module @@ -362,9 +380,10 @@ Consider the module C below. sub open { my $path = shift ; - if (warnings::enabled() && $path !~ m#^/#) { - warnings::warn("changing relative path to /tmp/"); - $path = "/tmp/$path" ; + if ($path !~ m#^/#) { + warnings::warn("changing relative path to /var/abc") + if warnings::enabled(); + $path = "/var/abc/$path"; } }