No, that's wrong. The warnings pragma is lexically (statically) scoped, not dynamically scoped.
{
package OtherModule;
use warnings;
sub routine { my $n = 0; my $i = $n + "a"; }
}
{
no warnings;
OtherModule->routine();
}
Argument "a" isn't numeric in addition (+) at 602580.pl line 4.
And unfortunately, use warnings; (and no warnings;) overrides $^W.
{
package OtherModule;
use warnings;
sub routine { my $n = 0; my $i = $n + "a"; }
}
{
local $^W = 0;
OtherModule->routine();
}
Argument "a" isn't numeric in addition (+) at 602580.pl line 4.
Update: The warnings was initially a compile-time warning. Fixed it to be a run-time warning.
|