Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Changing the return number for "die"

by dpuu (Chaplain)
on Jul 20, 2004 at 23:21 UTC ( #376115=note: print w/ replies, xml ) Need Help??


in reply to Changing the return number for "die"

If you want to do it one-off, then you can simply set $! before you call die. If you want to set it more globally, then you might try:

$SIG{__DIE__} = sub { $! = 42; die @_ };
If you ever catch errors using eval, then you might want to be a bit more careful:
$SIG{__DIE__} = sub { $! = 42 unless $^S; die @_ };
--Dave
Opinions my own; statements of fact may be in error.


Comment on Re: Changing the return number for "die"
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-08-20 17:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (120 votes), past polls