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
In reply to Re: best practice
by rchiav
in thread best practice
by George_Sherston
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |