in reply to best practice
...and cuddle my elses
I think if you look at perlstyle you'll see that they encourage not cuddling your elses. I'd imagine that the reason is (this is the reason I don't like cuddled elses anyway) that the "if" doesn't line up with the "else". Example..
Rich# cuddled - I feel that it's harder to read. if ($foo) { if ($bar) { print "We have a foo and a bar.\n"; } else { print "We have a foo.\n"; } } else { print "You have no foo.\n; } #uncuddled - one way (the way I use) if ($foo) { if ($bar) { print "We have a foo and a bar.\n"; } else { print "We have a foo.\n"; } } else { print "You have no foo.\n; }
update: as dragonchild and MeowChow point out, this is still something that people don't agree on. Some people write their elses (and subs for that matter) as MeowChow has shown. That's why I mentioned that my example was "one way". I just wanted to point out that you might have misread perlstyle
|
---|
Replies are listed 'Best First'. | |
---|---|
11. THOU SHALT CUDDLE THY ELSES
by dragonchild (Archbishop) on Aug 27, 2001 at 21:18 UTC | |
(MeowChow) Re2: best practice
by MeowChow (Vicar) on Aug 27, 2001 at 21:53 UTC | |
by herveus (Prior) on Aug 27, 2001 at 23:09 UTC | |
by MeowChow (Vicar) on Aug 28, 2001 at 00:06 UTC | |
by inverse (Acolyte) on Aug 28, 2001 at 05:27 UTC |
In Section
Seekers of Perl Wisdom