Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: A guide to coding Perl

by dingus (Friar)
on Dec 11, 2002 at 20:44 UTC ( #219169=note: print w/ replies, xml ) Need Help??


in reply to A guide to coding Perl

One thing I like to avoid is excessive brace nesting. Mostly because I find it hard to make sure I've got the end braces right. Yes smart editors help, as does indentation, but I like the perl "statement unless condition" syntax a lot in my loops.

What do I mean?

well I often see code like

while (cond1) { if (cond2) { statement; if (cond3) { statement; statement; for (range) { something; something; something; } } } else { last; } }
What I prefer to see/write is
while (cond1) { last unless (cond2); statement next unless (cond3); statement statement for (range) { something something something } }

Dingus


Enter any 47-digit prime number to continue.


Comment on Re: A guide to coding Perl
Select or Download Code
Re: Re: A guide to coding Perl
by rir (Vicar) on Dec 12, 2002 at 02:57 UTC
    Yes, yes, yes. Fallthrough is concise, natural and seemly.

    To my knowledge, I've only met two people, Pascal lovers both, who could not abide fallthrough. In their code, an if statement that could return was always followed by an else clause that contained the rest of the routine.

    To be fair: a couple more spaces in your indents and your first version would read much better.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-10-02 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (41 votes), past polls