In the scope of lexical warnings, the old warning state is ignored. According to perllexwarn,
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.So, go ahead and use warnings and selectivly enable/disable things as you need. The presence of -w on the command line (or explicit setting of the global flag) will not bother you.How Lexical Warnings interact with -w/$^W:
The combined effect of 3 & 4 is that it will allow code which uses the 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.
- If none of the three command line flags (-w, -W or -X) that control warnings is used and neither $^W or the 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 will work unchanged.
- The -w flag just sets the global $^W variable as in 5.005 -- this means that any legacy code that currently relies on manipulating $^W to control warning behavior will still work as is.
- Apart from now being a boolean, the $^W variable 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 warnings pragma, both the $^W variable 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.
Code outside of yours will continue to use the -w state; yours (containing use warnings) will hide that and use what you asked for. The hiding of -w by use warnings is itself lexically scoped.
Also, as specifically pertains to diagnostics.pm, Paul Marquess notes "I *think* I've got diagnostics to work with the lexical warnings patch, but there were design decisions made in diagnostics to work around the limitations of C<$^W>. Now that those limitations are gone, the module should be revisited."
In reply to Mixing lexical warnings with -w
by John M. Dlugosz
in thread strict, warnings and diagnostics pragmas
by tomazos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |