in reply to Imposing no warnings xxx upon callback code?
I can suppress all warnings using $^W
No, warnings overrides $^W/-w (regardless of their relative order).
use warnings; BEGIN { $^W = 0; } my $s = '' . undef(); # Use of uninitialized value
Not just use warnings;. no warnings; overrides $^W/-w too (regardless of their relative order).
no warnings; BEGIN { $^W = 1; } my $s = '' . undef(); # [No warnings]
In the context of your problem, $^W won't work if the sub was compiled with use warnings; in effect.
use strict; use warnings; sub test (&) { my $code = shift; local $^W = 0; $code->( undef ); } test { print "@_"; # Use of uninitialized value };
That leaves you with $SIG{__WARN__}. You can catch the warnings and filter out the ones you don't want.
Update: Adjusted formatting for coherence. Added example to show that no warnings; overrides $^W too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Imposing no warnings xxx upon callback code?
by BrowserUk (Patriarch) on Dec 22, 2006 at 16:38 UTC |