Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Breaking out of an 'if'

by bluto (Curate)
on Apr 14, 2005 at 16:26 UTC ( [id://447960]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Breaking out of an 'if'

One more old chestnut solution...

if ($some_condition){{ &some_stuff(); last if $another_condition; &some_more_stuff; }}

... though I don't tend to use this since I find the extra braces to be too subtle when rereading the code (i.e. someone, ok me, removes them since they look redundant which then changes the sematics of the surrounding code).

Replies are listed 'Best First'.
Re^2: Breaking out of an 'if'
by thor (Priest) on Apr 14, 2005 at 19:29 UTC
    I find the extra braces to be too subtle when rereading the code
    Whitespace is your friend:
    if ($some_condition){ { #heck, even comment the bare block &some_stuff(); last if $another_condition; &some_more_stuff; } }

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      Whitespace is your friend:

      That helps some, but to me it still looks like a cut/paste error without a comment. If you have to comment, I'm not sure what the point is (i.e. use something like one of the other solutions which is more self-describing), but of course YMMV. Now if you use this all of the time in the code you maintain then that's probably fine since it becomes an idiom (i.e. a programmer will see this code multiple times and realize it isn't a typo). I find that I rarely if ever do this so it would become more of a hazard than anything else to me...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://447960]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.