On Wed, Sep 20, 2000 at 07:06:21AM +1100, Damian Conway wrote:
>    > >This RFC proposes that the internal cursor iterated by the C<each>
>    > >function be stored in the pad of the block containing the C<each>,
>    > >rather than being stored within the hash being iterated.
>    > 
>    > Then how do you specify which iterator is to be reset when you wish 
>    > to do that? Currently, you do this by specifying the hash.
>    
>    > If the iterator is no longer affiliated with the hash, but the opcode node,
> 
> Just to note: in version 2 of the RFC, it's associated with the pad of
> the block in which the C<each> appears.

So you are suggesting that the first itteration of the loop reset
the iterator. THis is because currently

  %hash = ( aa => 1, bb => 2);

  while(my($k,$v) = each %hash) { print $k,"\n" }

is no different to

  foreach (1 .. keys %hash) {
    while(my($k,$v) = each %hash) {
      print $k,"\n";
      last if $_ == 1;
    }
  }

No if the iterator is associated with the scope how do I reset it
so that the itterator always starts at the beginning each time
and not only when it is called after having reach the end on the
previous time

>    > then what are you going to do?  
> 
> The short answer is that there is no "manual" reset of iterators.

Then you loos the ability to exit and reenter a scope continueing where
you left off.

Graham.

Reply via email to