Re: Index of foreach

2001-09-18 Thread Andrea Holstein
"Brett W. McCoy" wrote: > > 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 t

Re: Index of foreach

2001-09-18 Thread Rasoul Hajikhani
Thanks for all the help :) "Brett W. McCoy" wrote: > > 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]) { > > > >... > > > > } > > >

Re: Index of foreach

2001-09-17 Thread Brett W. McCoy
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 > >

Re: Index of foreach

2001-09-17 Thread Andrea Holstein
"Brett W. McCoy" schrieb: > > 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,

RE: Index of foreach [ot]

2001-09-17 Thread Sid Malhotra
: Re: Index of foreach Rasoul Hajikhani wrote: > > Hi there, > is there any way to know what is the "current" index value in a foreach > loop? > > EX: > > foreach my $var (@array) > { > # need the index of the array > } > > Thanks in advance.

Re: Index of foreach

2001-09-17 Thread Brett W. McCoy
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? -- Brett http://www.ch

Re: Index of foreach

2001-09-17 Thread Andrea Holstein
Rasoul Hajikhani wrote: > > Hi there, > is there any way to know what is the "current" index value in a foreach > loop? > > EX: > > foreach my $var (@array) > { > # need the index of the array > } > > Thanks in advance. > -r Try for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $

Re: Index of foreach

2001-09-17 Thread Brett W. McCoy
On Mon, 17 Sep 2001, Rasoul Hajikhani wrote: > Hi there, > is there any way to know what is the "current" index value in a foreach > loop? > > EX: > > foreach my $var (@array) > { > # need the index of the array > } Just index through the array this way: foreach my $var (0..$#array) {

Re: Index of foreach

2001-09-17 Thread P lerenard
you can run a counter inside the loop Pierre >From: Rasoul Hajikhani <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Index of foreach >Date: Mon, 17 Sep 2001 12:23:51 -0700 > >Hi there, >is there any way to know what is the "current" index value in

Index of foreach

2001-09-17 Thread Rasoul Hajikhani
Hi there, is there any way to know what is the "current" index value in a foreach loop? EX: foreach my $var (@array) { # need the index of the array } Thanks in advance. -r -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]