[HRPM] nother one

chicks at chicks.net chicks at chicks.net
Wed Nov 15 14:36:12 CST 2000


On Wed, 15 Nov 2000, Troy E. Webster wrote:
> 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.

Not as far as I know.  You'd have to do a for or while loop and keep track
of some iterator variable.

-- 
</chris>

"Pinky, you've left the lens cap of your mind on again." - The Brain




More information about the Norfolk-pm mailing list