[HRPM] nother one

Robert Kernell kernell at sundog.larc.nasa.gov
Wed Nov 15 14:52:27 CST 2000


Hmm, I just started learning Perl, but I don't think you can do it. Just a 
guess.

Maybe you could make a copy of the array and use that in your foreach loop to 
peek ahead.

> Hey,
> 
> This may turn out to be a stupid question, but nothing ventured nothing
> gained...
> 
> Is there a way to peek ahead in a foreach loop? 
> 
> For example, foreach $elem (@array){}
> can I look at $elem+1 while looking at $elem? I realize I can do the same
> type of loop using a while loop and then checking $array[i+1] (where i is
> the current element) but I was curious if there was a way to do it with
> a foreach loop.
> 
> Thanks
> Troy
> 


Bob Kernell
Research Scientist
Atmospheric Sciences Competency
Analytical Services & Materials, Inc.
email: r.w.kernell at larc.nasa.gov
tel: 757-827-4631




More information about the Norfolk-pm mailing list