|
|
|
Clear questions and runnable code get the best and fastest answer |
|
| PerlMonks |
Re: Checking the success of evalby ncw (Friar) |
| on Apr 20, 2001 at 21:55 UTC ( [id://74342]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
My favourite gotcha with eval is if you set a die
handler then the die handler is called even inside the
eval! In fact I consider this a bug in perl - as does
the author of "perldoc die" Eg This prints Caught by die handler: Oops. The fix goes like this :-
$SIG{__DIE__} = sub { print "Caught by die handler: $_[0]"; exit };
eval
{
local $SIG{__DIE__};
die "Oops\n";
};
print "Eval returned error: $@" if $@;
Which returns Eval returned error: Oops as anyone
would always want.
In Section
Meditations
|
|
||||||||||||||||||||||||||||||