in reply to Re^2: Designing a DWIMish interface for generator function
in thread Designing a DWIMish interface for generator function
You need something external to the loop to keep the state.
You could use a combination of the address of the calling opcode as a key to get the appropriate state, but you'd have no way to reset to the counter if you did that, so you wouldn't be able to last/return/die from within the loop.
Just look at each for example. To properly use each, you need to do:
keys %hash; # Reset iterator while (my ($k, $v) = each(%hash)) { ... }
And even then, it doesn't nest because the iterator is per-hash, not per-each.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Designing a DWIMish interface for generator function
by LanX (Saint) on Feb 01, 2010 at 04:42 UTC | |
by ikegami (Patriarch) on Feb 01, 2010 at 05:53 UTC | |
by LanX (Saint) on Feb 01, 2010 at 11:12 UTC |