good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Bizarre Proc::Daemon error # die-handlerby LanX (Saint) |
on Jun 10, 2014 at 03:09 UTC ( [id://1089378]=note: print w/replies, xml ) | Need Help?? |
> a) Why is the script dying when executing an expression in an eval? Isn't that the whole point of eval? Your die handler is called from within the block eval and dies like you told him to do. ( update: or maybe not?) You might(?)¹ be able to check the caller to avoid dieing in block-eval.
== Updates
=== From perlvar
Due to an implementation glitch, the $SIG{__DIE__} hook is called even inside an eval(). Do not use this to rewrite a pending exception in $@, or as a bizarre substitute for overriding "CORE::GLOBAL::die()". This strange action at a distance may be fixed in a future release so that $SIG{__DIE__} is only called if your program is about to exit, as was the original intent. Any other use is deprecated.
=== Possible workaround¹) Indeed! As you can see from this test, does caller(1) tell you if the die appeared within an eval . So better avoid to die in that case! :) (But you should check the whole caller-chain till top-level for the string (eval) )
-->
=== "may be fixed in a future release"Well, I wonder why this was never fixed, if a simple check of caller is sufficient.
Cheers Rolf (addicted to the Perl Programming Language)
In Section
Seekers of Perl Wisdom
|
|