in reply to Re: Imposing no warnings xxx upon callback code?
in thread Imposing no warnings xxx upon callback code?

As I fruitlessly tried to explain to you privately, $SIG{__DIE__} is not appropriate here. $SIG{__WARN__} is required. Maybe if I post a test you can run...

use strict; use warnings; $SIG{__DIE__} = sub { my $wn = shift; return if $wn =~ /Use of uninitialized value/i; #Most annoying return if $wn =~ /name "(?:.+?)" used only once/i; #Very annoying warn $wn; }; print 123 + undef, "\n"; # We want to hide this warning. print 123 + 'abc', "\n"; # We want to see this warning.

outputs

Argument "abc" isn't numeric in addition (+) at 591379.pl line 12. Use of uninitialized value in addition (+) at 591379.pl line 11. 123 123

If you change $SIG{__DIE__} to $SIG{__WARN__}, you get the desired output.

Argument "abc" isn't numeric in addition (+) at 591379.pl line 12. 123 123

Update: Regarding your update, $SIG{} = sub { ... }; is no good either. It's a syntax error.

Replies are listed 'Best First'.
Re^3: Imposing no warnings xxx upon callback code?
by SFLEX (Chaplain) on Dec 22, 2006 at 19:45 UTC
    ya, I can be wrong!
    $SIG{__WARN__} = sub { my $wn = shift; return if $wn =~ /Use of uninitialized value/i; #Most annoying return if $wn =~ /name "(?:.+?)" used only once/i; #Very annoying warn $wn; };

    Good Luck!