in reply to Managing errors in subroutines

You could always just have your sub routines return 1 or 0 and set a param with the error message, and then instead of this:

$error_msg = sub1();
return $error_msg if ($error_msg ne ());

you can do this:

return $error_param if not sub1();

Godzirra!
Destroying Neo Tokyo since 1954

Replies are listed 'Best First'.
Re: Re: Managing errors in subroutines
by Improv (Pilgrim) on Apr 16, 2003 at 12:39 UTC
    It's possible to do better than that. Remember Perl's notions of truth can be applied to more than just numeric values. Just return "" if there's no error (which evaluates to false), and return whatever error string is appropriate otherwise, which will evaluate to true.