Date: Fri, 06 Jul 2001 20:54:03 -0700 From: "$Bill Luebkert" Subject: Re: Why for loop not working?? Message-Id: <3B4687DB.4D8AF6D2@wgn.net> "Carlos C. Gonzalez" wrote: > > In article <9i5rei$374@dispatch.concentric.net>, jkeen@concentric.net > says... > > > Your "for" loop is missing the test condition from the 2nd element in the > > parens. > > for (my $i=0; $i <= $#temp; $i++) > > Boy oh boy I thought I was starting to get the hang of some of this > *grin*. What does "$i <= $#temp" mean? > > I can make out some of it such as... > > while the value of $i is less than or equal to ??? (something about > temp). > > but how can I compare a numeric value to $#temp?? What does $#temp mean? I prefer: for (my $ii = 0; $ii < @temp; $ii++) { $#temp is the last array index of @temp. By using @temp instead (in a scalar context) you get the full array size and can use < instead of <= for the comparison. If @temp has 6 elements, $# is equal to 5 (the index of the last element of the array).