in reply to Re: Ouch! Each! Reentrant it is not
in thread Ouch! Each! Reentrant it is not
Then, try this:%a = ( A=>0, B=>1, C=>2 ); %b = %a; print each %b, "\n"; { local %b = %a; each %b; } while(($k,$v)=each %b) { print $k, $v, "\n" }
The problem with local %h = %h is not that the local copy shares the iterator, but that the original %h gets its iterator reset by being read. This is mentioned briefly in the documentation for the each function.%h = ( A=>0, B=>1, C=>2 ); print each %h, "\n"; () = %h; print each %h, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Ouch! Each! Reentrant it is not
by BrowserUk (Patriarch) on Jul 15, 2005 at 20:31 UTC |