&$code; # call the wrapped sub if (CODE DIED) { # do something about that and let the die() happen } else { # do something else } #### eval { &$code; }; # call the wrapped sub if ($@) { # do something about that and let the die() happen } else { # do something else }