On 7/30/07, John W. Krahn <[EMAIL PROTECTED]> wrote: > Chas Owens wrote: > > On 7/30/07, Isha M. Renta <[EMAIL PROTECTED]> wrote: > >> The 13 is the counter for the $inittime array (which actually have 13 > >> numbers and not 15 as it seems) and the 3600 is the number of lines in all > >> the files. All the files have 3600 lines. > >> > >> Isha > > snip > > > > Then you have an off-by-one error. You are saying > > > > for($j=0;$j<=13,$j++) { > > > > This will loop 14 times, not 13 times. This is why C-style for loops > > are bad. Don't use them. If you want to loop over an array use the > > iterating version of for: > > > > for my $element (@array) {} > > > > If you want to loop over a range you still should use the iterating > > version of for: > > > > for my $j (1 .. 13) {} > > It would probably be better to use: > > for my $j ( 0 .. $#array ) {} snip
No, that is almost always better written as for my $element (@array) {} You should only use a range if you want to iterate a specific number of times or you want to iterate over that range. Using the position of last the last element in an array is a big clue that you really want to iterate over an array, not a range. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/