Eg
This prints Caught by die handler: Oops.$SIG{__DIE__} = sub { print "Caught by die handler: $_[0]"; exit }; eval { die "Oops\n"; }; print "Eval returned error: $@" if $@;
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 reply to Re: Checking the success of eval
by ncw
in thread Checking the success of eval
by ton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |