On Tue, 18 Sep 2001, Andrea Holstein wrote:
> > On Tue, 18 Sep 2001, Andrea Holstein wrote:
> >
> > > Try
> > > for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $var =
> > > $array[++$i]) {
> > > ...
> > > }
> >
> > Good Heavens! Why would you go to all of that trouble when a simple
> > foreach will do?
> >
> You're right,
> but
> foreach my $var (0..$#array) {
> ...
> }
>
> has to create a new list (0..$#array) of the same size as @array.
Then you can use 'for(my $i = 0; $i < @array; $i++)'. In your example
above, you are incrementing $i twice (first postincrement, then
preincrement). It doesn't make sense (to me, at least) to have an index
counter, and then still assign the array element to a temp variable.
Just loop through the array with the counter and use the array directly.
-- Brett
http://www.chapelperilous.net/
------------------------------------------------------------------------
Your CHEEKS sit like twin NECTARINES above a MOUTH that knows no BOUNDS --
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]