|Perl Language Reference Manual|
by Larry Wall and others
Paperback (6"x9"), 724 pages
RRP £29.95 ($39.95)
Sales of this book support The Perl Foundation! Get a printed copy>>>
24.4 Backward Compatibility
If you are used with working with a version of Perl prior to the
introduction of lexically scoped warnings, or have code that uses both
lexical warnings and
$^W, this section will describe how they interact.
How Lexical Warnings interact with -w/
If none of the three command line flags (-w, -W or -X) that
control warnings is used and neither
warningspragma 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 will work unchanged.
The -w flag just sets the global
$^Wvariable as in 5.005. This means that any legacy code that currently relies on manipulating
$^Wto control warning behavior will still work as is.
Apart from now being a boolean, the
$^Wvariable operates in exactly the same horrible uncontrolled global way, except that it cannot disable/enable default warnings.
If a piece of code is under the control of the
warningspragma, both the
$^Wvariable and the -w flag will be ignored for the scope of the lexical warning.
- The only way to override a lexical warnings setting is with the -W or -X command line flags.
The combined effect of 3 & 4 is that it will allow code which uses
warnings pragma to control the warning behavior of $^W-type
code (using a
local $^W=0) if it really wants to, but not vice-versa.
|ISBN 9781906966027||Perl Language Reference Manual||See the print edition|