all -+
|
- +- chmod
+ +- assertions
|
+- closure
|
+ +- deprecated
+ |
+- exiting
|
+- glob
| |
| +- exec
| |
+ | +- layer
+ | |
| +- newline
| |
| +- pipe
| |
| +- bareword
| |
- | +- deprecated
- | |
| +- digit
| |
| +- parenthesis
|
+- taint
|
- +- umask
+ +- threads
|
+- uninitialized
|
To determine which category a specific warning has been assigned to see
L<perldiag>.
+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
warning.
use warnings ;
-
+
time ;
-
+
{
use warnings FATAL => qw(void) ;
length "abc" ;
}
-
+
join "", 1,2,3 ;
-
+
print "done\n" ;
When run it produces this output
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
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";
}
}
bless [], $class ;
}
-
+
1 ;
The code below makes use of both modules, but it only enables warnings from