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

Re: Exiting script from subs

by graq (Curate)
on Apr 15, 2005 at 16:34 UTC ( [id://448250]=note: print w/replies, xml ) Need Help??


in reply to Exiting script from subs

I would personally not want to hide an exit statement inside a block like that.
It strikes me that what you want is for the program to end (as opposed to abend) based on certain criteria.
This makes it look a little like this:
my $result = do_task(); exit() if ($result eq 'exit'); sub do_task { ... do something... if ($somecondition) { return 'exit'; } }
Obviously the string 'exit' is not that desirable (and for the sake of your example), but the return code should depend on what the function does (and allow for further scope).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-25 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found