Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: How can I suppress 'uninitialized' warnings in a CPAN module?

by LanX (Canon)
on Nov 17, 2013 at 23:04 UTC ( #1063017=note: print w/ replies, xml ) Need Help??


in reply to Re: How can I suppress 'uninitialized' warnings in a CPAN module?
in thread How can I suppress 'uninitialized' warnings in a CPAN module?

> I have 2 questions, are these 2 lines correct?

Correct yes but...

> line 14 : local $SIG{__WARN__} = \&suppress_UV_warning;

Personally I prefer anonymous subs if I never need to call them by name.

> line 50 : warn $message;

You should check the Perl-version, IIRC this causes an endless loop in Perl older < 5.8 (?) (Too lazy to look up when it was exactly fixed)

Newer versions are fool proof. ;-)

update

Talking about "generic solutions":

Please be aware that this approach doesn't help if the module in question is also recklessly overwriting $SIG{__WARN__}

Therefore a safe way of overriding is to create a wrapper, which calls the overridden handler from within (if present in $SIG{__WARN__}).

But you can only be sure after checking the source code of the module in question.

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re^2: How can I suppress 'uninitialized' warnings in a CPAN module?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1063017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-07-10 04:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (198 votes), past polls