Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Entering and exiting subs in style

by edoc (Chaplain)
on May 26, 2004 at 03:20 UTC ( #356446=note: print w/replies, xml ) Need Help??


in reply to Entering and exiting subs in style

I'd say you want to do some (which could easily become "LOTS of") reading up on exception handling which basically involves calling 'die' in one form or another and then catching it further up your code tree. This is a fairly large subject matter so I'll just refer you to some existing threads.. 8) ..exception handling.

Greatly simplified, untested code..

#--------- 1 ------------ eval { foo() }; if ($@){ # Houston, we have a problem my $error = $@; } else { # everythings ok. } sub foo { &bar; } sub bar { if ($negative) { die('bar is negative'); } return(); }

cheers,

J

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2022-01-25 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (66 votes). Check out past polls.

    Notices?