You're looking for some sort of throw/catch error-handling for special subs.
eval { some_sub() }; if ($@) { # Handle exception here } sub some_sub { die "Bad stuff happened" if $some_exception_happens; }
That's the way Perl does it.

Now, for a stylistic note - you shouldn't be doing the eval/$@ syntax for every single function call you make. Keep it for the critical parts of your system. In part, this is because of the overhead of eval. *shrugs*

Update: I stand corrected on the overhead. Thanks, btrott!

We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

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

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