Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Idomatic Handling of Subroutine Error

by blakem (Monsignor)
on Sep 18, 2001 at 22:50 UTC ( [id://113172]=note: print w/replies, xml ) Need Help??


in reply to Idomatic Handling of Subroutine Error

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://113172]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found