This one scores highest on readability. I assert that the other ones are too hard to understand and, thus, more likely to be buggy (i.e. off-by-one errors).
I think the best version is simply:
for ( my $i = 0; $i @_; $i += 2 ) {...
}
It clearly selects even numbers and ends before just before the end of the array. The "@_" is more readable than "$#_", I say.
Re: (Score:1)
?
Re: (Score:1)
perl -e 'print "Just another Perl ${\(trickster and hacker)},";'
The Sidhekin proves that Sidhe did it!
Re: (Score:1)
Same thing as Ovid’s, only painted green. Both his and yours make two to throw one away, whereas the approach I took does not.
Re: (Score:1)
perl -e 'print "Just another Perl ${\(trickster and hacker)},";'
The Sidhekin proves that Sidhe did it!
Readability (Score:1)
I think the best version is simply:
for ( my $i = 0; $i @_; $i += 2 ) {
}
It clearly selects even numbers and ends before just before the end of the array. The "@_" is more readable than "$#_", I say.
Re:Readability (Score:1)
?
The most readable is actually if you can afford to destroy the array, which in Ovid’s case is probably true (because it is usually true for
@_):