NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
every loop a method (Score:2)
In one of his talks (Enterprise Perl?) James Duncan discussed readable code and gives the excellent advice that every loop should be a method. I find myself doing this more with Java than Perl, probably because I hit the mental ceiling for method length with Java's verbosity. So I'd typically translate your example to a method like:
One side-effect of Java's not having unless is that I tend to write both 'isSomething' and 'isNotSomething' for readability, especially because an '!' always gets lost:
The first example is particularly difficult to read when developers don't use sufficient whitespace, like:
or even the painful:
I'm always surprised that I rarely see discussions of whitespace in code readability. Do people consider this a religious issue like where to put braces?
Reply to This
Whitespace (Score:2)
vs
And they literally didn't see the difference. It's quite depressing.
-Dom
Re:Whitespace (Score:2)
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;