}
When this code is run with the B<-w> flag, a warning will be produced
-for the C<$a> line -- C<"Reversed += operator">.
+for the C<$a> line: C<"Reversed += operator">.
The problem is that Perl has both compile-time and run-time warnings. To
disable compile-time warnings you need to rewrite the code like this:
=head2 Backward Compatibility
-If you are used with working with a version of Perl prior to the
+If you are used to working with a version of Perl prior to the
introduction of lexically scoped warnings, or have code that uses both
lexical warnings and C<$^W>, this section will describe how they interact.
=item 1.
If none of the three command line flags (B<-w>, B<-W> or B<-X>) that
-control warnings is used and neither C<$^W> or the C<warnings> pragma
+control warnings is used and neither C<$^W> nor the C<warnings> pragma
are used, then default warnings will be enabled and optional warnings
disabled.
This means that legacy code that doesn't attempt to control the warnings
=item 2.
-The B<-w> flag just sets the global C<$^W> variable as in 5.005 -- this
+The B<-w> flag just sets the global C<$^W> variable as in 5.005. This
means that any legacy code that currently relies on manipulating C<$^W>
to control warning behavior will still work as is.
The current hierarchy is:
- all -+
- |
- +- closure
- |
- +- deprecated
- |
- +- exiting
- |
- +- glob
- |
- +- io -----------+
- | |
- | +- closed
- | |
- | +- exec
- | |
- | +- layer
- | |
- | +- newline
- | |
- | +- pipe
- | |
- | +- unopened
- |
- +- imprecision
- |
- +- misc
- |
- +- numeric
- |
- +- once
- |
- +- overflow
- |
- +- pack
- |
- +- portable
- |
- +- recursion
- |
- +- redefine
- |
- +- regexp
- |
- +- severe -------+
- | |
- | +- debugging
- | |
- | +- inplace
- | |
- | +- internal
- | |
- | +- malloc
- |
- +- signal
- |
- +- substr
- |
- +- syntax -------+
- | |
- | +- ambiguous
- | |
- | +- bareword
- | |
- | +- digit
- | |
- | +- parenthesis
- | |
- | +- precedence
- | |
- | +- printf
- | |
- | +- prototype
- | |
- | +- qw
- | |
- | +- reserved
- | |
- | +- semicolon
- |
- +- taint
- |
- +- threads
- |
- +- uninitialized
- |
- +- unpack
- |
- +- untie
- |
- +- utf8
- |
- +- void
+ all -+
+ |
+ +- closure
+ |
+ +- deprecated
+ |
+ +- exiting
+ |
+ +- experimental --+
+ | |
+ | +- experimental::lexical_subs
+ |
+ +- glob
+ |
+ +- imprecision
+ |
+ +- io ------------+
+ | |
+ | +- closed
+ | |
+ | +- exec
+ | |
+ | +- layer
+ | |
+ | +- newline
+ | |
+ | +- pipe
+ | |
+ | +- unopened
+ |
+ +- misc
+ |
+ +- numeric
+ |
+ +- once
+ |
+ +- overflow
+ |
+ +- pack
+ |
+ +- portable
+ |
+ +- recursion
+ |
+ +- redefine
+ |
+ +- regexp
+ |
+ +- severe --------+
+ | |
+ | +- debugging
+ | |
+ | +- inplace
+ | |
+ | +- internal
+ | |
+ | +- malloc
+ |
+ +- signal
+ |
+ +- substr
+ |
+ +- syntax --------+
+ | |
+ | +- ambiguous
+ | |
+ | +- bareword
+ | |
+ | +- digit
+ | |
+ | +- illegalproto
+ | |
+ | +- parenthesis
+ | |
+ | +- precedence
+ | |
+ | +- printf
+ | |
+ | +- prototype
+ | |
+ | +- qw
+ | |
+ | +- reserved
+ | |
+ | +- semicolon
+ |
+ +- taint
+ |
+ +- threads
+ |
+ +- uninitialized
+ |
+ +- unpack
+ |
+ +- untie
+ |
+ +- utf8 ----------+
+ | |
+ | +- non_unicode
+ | |
+ | +- nonchar
+ | |
+ | +- surrogate
+ |
+ +- void
Just like the "strict" pragma any of these categories can be combined
sub-category of the "syntax" category. It is now a top-level category
in its own right.
-
=head2 Fatal Warnings
X<warning, fatal>
Notice also that the warning is reported at the line where the object is first
used.
+When registering new categories of warning, you can supply more names to
+warnings::register like this:
+
+ package MyModule;
+ use warnings::register qw(format precision);
+
+ ...
+
+ warnings::warnif('MyModule::format', '...');
+
=head1 SEE ALSO
L<warnings>, L<perldiag>.