Just for fun, take a look at "Falsify" scalar strings. Its a quick hack that overloads certain strings so that they act FALSE in boolean context. For instance, you could have the odd looking construct:
unless ($error_or_result = my_sub()) { # FALSE in boolean context # but still contains text when stringified die "Your error was: $error_or_result\n"; } print "Your result was $error_or_result\n";
Not recommended for production code (for one thing maintanence would be a beast) but fun to play with...

-Blake


In reply to Re: Idomatic Handling of Subroutine Error by blakem
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":