There is not for either for or foreach. This is generally not a problem
in for as programmers generally use an interation variable as a for's
termination condition. i.e. :
  for (my $i = 0; $i < length (@array); $i++)
which is how you can loop over an array and have an interation variable.
It is a problem in foreach like in your example. (you meant to write
foreach in your example and not for, right?) This is why they are
considering (or maybe have come to a final descion since I last looked)
adding a variable to do this. Damian seemed to be a big supporter of
this. It'll very likely be in perl6.

-mike

On Mon, Dec 09, 2002 at 11:56:39AM +0700, Komtanoo Pinpimai wrote:
> Hello
>   Sorry if it has already been listed in a perl document, however I cannot 
>   discover it,
> 
> My curiosity is that:
> 
>       Is there the "iterator variable" for "for or foreach" loop ?
>       At this present, when I need access to get current index of an array 
>       when looping with for, I do this
> 
>       my $counter=0;
>       for (@array) {
>               #do something
> 
>               print $another_array[$counter];
>               ++$counter;
>       }
> 
> you see? It is not elegant.. has perl this iterator variable ?
> 
> 
> _______________________________________________
> Boston-pm mailing list
> [EMAIL PROTECTED]
> http://mail.pm.org/mailman/listinfo/boston-pm
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to