Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Are there any other statements that are like return if...?

by shoness (Friar)
on Jun 27, 2008 at 19:07 UTC ( [id://694433]=note: print w/replies, xml ) Need Help??


in reply to Are there any other statements that are like return if...?

Realize that "important stuff" needs to be on the left side of the page because few people have the time to read entire lines to figure out what's going on. ☺

Using this "backwards" style, your code intent stays more visible.

For example, it's common to do this for something like:

print "Here we are..." if $debugging;
Often I'll decide one way or the other based on whether it's a special case or normal case. Be careful though, since as others have pointed out, you can obscure intent as well. Mixing them up, as with this block, I find confusing at a glance. Changing the indentation can help.
if ($unlikely_condition) { &do_that_voodoo; } &that_yoodoo if $typical_case;
Cheers!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-16 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found