Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Entering and exiting subs in style

by edoc (Chaplain)
on May 26, 2004 at 03:20 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2024-04-23 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found