http://www.perlmonks.org?node_id=108175


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..

# 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; }
Rich

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