in reply to Handling non-fatal method error strings without exceptions or globals?
Another option is to have your functions return multiple values:
my ($result, $error) = function($arg); if ($error) { # do something... }
One caveat is that if for some reason you want to disregard the error and only want the result, you need to remember to use parentheses:
($result) = function($arg); # get the result only $result = function($arg); # WRONG!!! gets the error only
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Handling non-fatal method error strings without exceptions or globals?
by sleepingsquirrel (Chaplain) on Jan 19, 2005 at 16:51 UTC |
In Section
Seekers of Perl Wisdom