Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Idomatic Handling of Subroutine Error

by andye (Curate)
on Sep 19, 2001 at 15:21 UTC ( [id://113291]=note: print w/replies, xml ) Need Help??


in reply to Idomatic Handling of Subroutine Error

You're after something like this:
unless ( $result = my_sub() ) { # handle error condition }
I've often seen this, which is quite similar:
my $result; unless ( my_sub(\$result) ) { # handle error condition }
where &my_sub might look like this:
sub my_sub { my $r_result = shift; $$r_result = whatever(); was_there_an_error() ? 0 : 1 ; }
andy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-04-18 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found