in reply to Re: Getting the next array element while still keeping the current one
in thread Getting the next array element while still keeping the current one
Here is another attempt at making this readable and small ..(And , hopefully, correct)
Update:Noticed and Fixed Bug: Changed <= to <, @a[[$i]] to @a[[$i+1]].my @a=qw( wilma fred barney betty pebbels dino ); for (my ($i,$p,$c,$n)=(0,undef,@a); $i < scalar @a; $i++,($p,$c,$n) = ($c,$n,$a[$i+1])){ print qq($i Prev=$p \tCurr=$c \tNext=$n\n) } -- Output -- 0 Prev= Curr=wilma Next=fred 1 Prev=wilma Curr=fred Next=barney 2 Prev=fred Curr=barney Next=betty 3 Prev=barney Curr=betty Next=pebbels 4 Prev=betty Curr=pebbels Next=dino 5 Prev=pebbels Curr=dino Next=
By guaranteeing freedom of expression, the First Amendment also guarntees offense.
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Getting the next array element while still keeping the current one
by parv (Parson) on May 02, 2004 at 18:23 UTC | |
by NetWallah (Canon) on May 03, 2004 at 16:32 UTC | |
by parv (Parson) on May 05, 2004 at 04:58 UTC |