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.


In reply to Re^2: Imposing no warnings xxx upon callback code? by ikegami
in thread Imposing no warnings xxx upon callback code? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.