Pete Sergeant writes:
> I don't know how familiar you are with perlstyle, but I would have thought
> you would be quite familiar. It seems somewhat hypocritical to include
> comments such as:
>
> "Similarly, just because an operator lets you assume default arguments
> doesn't mean that you have to make use of the defaults. The defaults are
> there for lazy systems programmers writing one-shot programs. If you want
> your program to be readable, consider supplying the argument."
>
> and then do the opposite in the FAQs.
That's a bug in perlstyle :-)
There are times and places for $_, and making the blanket statement
that only bad little sysadmins use it is just as wrong as the blanket
statement that it should be always used.
In this case, I can buy that $_ is out of place. The reason for this
is that the code mentions $_ twice simply to get the benefit of not
having to mention it once! I get suspicious of code that mentions $_
explicitly.
> "For instance ** open(FOO,$foo) || die "Can't open $foo: $!"; ** is better
> than ** die "Can't open $foo: $!" unless open(FOO,$foo); ** because the
> second way hides the main point of the statement in a modifier."
That's also a nice rule of thumb, but your rewrite isn't really that
much easier to understand.
The
1 while ...
idiom is pretty well-established. It means "do this until you can't
do it any more". I don't think it's any more clear to say
while (...) { }
(you don't need the lone semicolon in the curlies)
I've just checked in some changes based on your suggestions. Find it
by searching for "commify" in
http://cvs.perl.org/cvsweb/perlfaq/perlfaq5.pod?rev=1.1&content-type=text/x-cvsweb-markup
So ... "Thanks, applied". Oooh, it felt good to say that :-)
Nat