Here's a rather funky example taken from the perl docs (man perlsub) that may provide a worthwhile solution -
sub try (&@) { my($try,$catch) = @_; eval { &$try }; if ($@) { local $_ = $@; &$catch; } } sub catch (&) { $_[0] } try { die "phooey"; } catch { /phooey/ and print "unphooey\n"; };
This is simliar to a lot of the above posts, in that it eval()s and then handles any errors. Although it's not *exactly* the sub wrapper you were looking for, I think it's a very cool alternative (but then again I'm impressed by all things functional ;o)
HTH

broquaint


In reply to Re: Idomatic Handling of Subroutine Error by broquaint
in thread Idomatic Handling of Subroutine Error by dvergin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":