Eric Walker wrote: > > perlknucklehead > > > > On Thu, 2003-12-18 at 17:07, Paul Johnson wrote: > > On Thu, Dec 18, 2003 at 04:57:26PM -0700, Eric Walker wrote: > > > > > > Hello all > > > > While traversing a loop across and array, how can I access array > > > > positions further down the array, like say if I am on a loop looking at > > > > position 23, how can I check the value of say position 24 or 32 while my > > > > loop counter is on position 23. > > > > Hmmm? Add 1 or 9 to your loop counter? > > > > Or have you not actually got a loop counter? If that is the case the > > easiest solution is probably to get one. > > > > Or have I completely misunderstood? Showing the code is usually more > > productive than simply describing the problem. > > > > I got it so I need a counter which sends me to a for loop instead of a > > foreach. Thanks..
You may want to use 'foreach' and just keep track of the current index. That gives you the extra speed and clarity of 'foreach' but still gives you an index to work with. Like this: my $i = 0; foreach (@array) { : $i++; } HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>