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

Re: Entering and exiting subs in style

by pg (Canon)
on May 27, 2004 at 01:16 UTC ( [id://356777]=note: print w/replies, xml ) Need Help??


in reply to Entering and exiting subs in style

You should never call exit from more than one place in your code. If you do, that would become a maintenance nightmare to other people, who might support your code.

More importantly, there is absolutely no logical need for this kind of style, as your code should always be coded in a way decent enough to handle all exceptions, and properly return from subs accordingly.

If your code does not do that, then fix it, not to tolerate it.

Indeed, this breaks modulization, as now other modules are performing functionality (in this case, exit function) that should only be performed by your main module.

Purity is not a kind of requirement, but a kind of belief.

Replies are listed 'Best First'.
Re: Re: Entering and exiting subs in style
by melora (Scribe) on May 27, 2004 at 18:45 UTC
    Why is using return() inadequate? I think I missed that part. Is it a matter of style and personal preference? I usually use return in all cases, and use returned values to distinguish a "die" situation from a successful return. Part of the reason is that I sometimes need to give the program a chance to "put away its crayons", so to speak. I realize, of course, that there's more than one way to do it. I just want to ask whether I'm missing out by doing it in my old-fashioned way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-29 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found