Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: wishlist: die-on-failure for built-ins

by dpuu (Chaplain)
on Apr 19, 2005 at 18:22 UTC ( #449372=note: print w/ replies, xml ) Need Help??


in reply to Re: wishlist: die-on-failure for built-ins
in thread wishlist: die-on-failure for built-ins

Second: if what you wish were possible (and easy), that wouldn't work, you'd wish your wish back. Sometimes you want it to die, sometimes - do smth. else.

I often code things as:

sub foo { my $error = ...; return $error if (defined wantarray || ! $error); croak "foo failed: $error"; }
Now you have a choice. If you check the return value (or assign it to undef), then it won't die. If you're lazy and there's an error, then it dies.

--Dave
Opinions my own; statements of fact may be in error.


Comment on Re^2: wishlist: die-on-failure for built-ins
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2015-07-07 13:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls