Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Best way to replace 'die' with 'warn'

by bv (Friar)
on Dec 06, 2009 at 03:59 UTC ( [id://811302]=note: print w/replies, xml ) Need Help??


in reply to Best way to replace 'die' with 'warn'

Perhaps someone more knowledgeable could clarify, but perlmod seems to indicate that you can set the %SIG hash as a package variable, so you could do something like this:

use Weather::Com; $Weather::Com::SIG{__DIE__} = sub { warn(@_) };

I think that would cover every call to die() from within the Weather::Com package. Inspection of @_ within your new handler could let it die if something was really a big problem.


@_=qw; Just another Perl hacker,; ;$_=q=print "@_"= and eval;

Replies are listed 'Best First'.
Re^2: Best way to replace 'die' with 'warn'
by puterboy (Scribe) on Dec 06, 2009 at 10:36 UTC
    That works nicely!

    Though I still have to wrap each function call with an eval...

    I still hope that a seasoned "monk" could verify that other than changing the behavior of die, the addition of the 'eval' command won't change the behavior of anything else. Or if it does, then help me understand what other side effects adding 'eval' could have

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-24 04:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found