in reply to Re^5: Why eval {...};if ($@) { die $@ } else { ...???
in thread Why <c>eval {...};if ($@) { die $@ } else { ...</c> ???
So if I understand right ... you might want to die somewhere else just in case the $SIG{__DIE__} was set differently? Or maybe so that it's called several times?
use Carp; $SIG{__DIE__} = sub {print STDERR "handler called\n"}; eval { eval { confess "blah\n"; }; if ($@) { die $@; } }; print $@ if $@;
I don't think I would want that ever. Actually I think $SIG{__DIE__} should be avoided due to the way it's implemented. Let's see what does perlvar say:
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.
|
|---|