Just a note, but I believe reading that in Perl6, we will have $# hold the current index of a for or foreach loop. Excellent idea I think. Sid. -----Original Message----- From: Andrea Holstein [mailto:[EMAIL PROTECTED]] Sent: Monday, September 17, 2001 10:45 PM To: [EMAIL PROTECTED] Subject: 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. > -r Try for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $var = $array[++$i]) { ... } Greetings, Andrea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]