in reply to Caller, caller, wherefore art thou, caller?
"I'll just mark my position with caller and if each() isn't called from the same spot, automatically reset the index."
Not addressing the question directly - but I'd not like this behaviour even if you could do it. Consider the case when you go back to the same location without having accessed the hash in between. Would it really make sense for it to carry on from the same position?
Personally I'd abstract out a separate iterator so you would do something like:
my $array = Array::AsHash->new({array => \@array}); { my $next_key_value = $array->each; while ( my ($key, $value) = $next_key_value->() ) { print "$key : $value\n"; last if some_condition($key, $value); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Caller, caller, wherefore art thou, caller?
by Aristotle (Chancellor) on Oct 10, 2005 at 20:52 UTC | |
by adrianh (Chancellor) on Oct 11, 2005 at 07:57 UTC |