[cvsnt] clueless about commitinfo

Czarnowski, Aric aczarnowski at unimax.com
Tue Feb 15 19:44:18 GMT 2005


> for ( my $x =0 ; $x < @ARGV ; $x++ ) {
> 
> $#ARGV is the last element number of the array 
> @ARGV, @ARGV is the count of elements.

As a Perl hack I'd offer this as a much clearer form of the for() loop:

 for ( my $x =0 ; $x < scalar(@ARGV) ; $x++ ) {}

Your version works because the return value of a list in scalar context
is the number of elements but unless you are a heavy Perl user that is
pretty obscure and one reason a lot of people say Perl is unreadable.
The scalar() call makes that explicit and I think it's easier to grok. 

Having said that, the more often seen and understood way to loop over
each element in a list is:

 foreach my $x (@ARGV) {}


http://www.perl.com/pub/a/2000/04/raceinfo.html
http://www.perl.com/pub/a/2000/06/commify.html

Glad it's working for you in any case,
Aric

Aric Czarnowski
Unimax Systems Corporation
612-204-3634



More information about the cvsnt mailing list