in reply to Re^2: Customizing the 'die' funtion
in thread Customizing the 'die' funtion

Yes, you can also literally redefine die using a typeglob in a BEGIN block, but I would disagree that this is generally what one would want. If you want to prevent die from killing your script, I think it is far better to trap potential dies in eval blocks, since you won't violate assumptions made in code you are calling (like having an open fail and still trying to process input). If you are not calling any external code, there is (generally) no reason to be using die in the first place if you don't want to throw exceptions.

Certainly in the case of the OP, there is no indication that the exception should be prevented.

Replies are listed 'Best First'.
Re^4: Customizing the 'die' funtion
by educated_foo (Vicar) on Apr 27, 2010 at 19:32 UTC
    Sure, if you just want to catch an error, eval is what you want. My point is that if you're reaching for $SIG{__DIE__}, you're almost certainly doing something wrong. For example, if you want to create resumable exceptions or drop into the debugger before unwinding the stack on a die, CORE::GLOBAL::DIE is what you want.