On 2012.5.14 2:06 AM, demerphq wrote: > On 14 May 2012 02:17, Michael G Schwern <schw...@pobox.com> wrote: >> So much hate for tying the iterator to the data and not the op. > > Indeed. I see this bite people regularly at $work (non Perl > programmers converting seem to get bitten by each() at least once in > their career). > > In the case of hashes I think tying it to the op would also be bad. > > I kinda wish perl had an interface like > > my $iter= iterator(%hash); > > while (my ($key,$value)= $iter->each) { > }
perl5i has that. Through the magic of autoboxing you don't even need the iterator. use perl5i::2; my %things = ( foo => 23, bar => 42 ); %things->each( func($k, $v) { say "Key: $k, Value: $v" }); -- Look at me talking when there's science to do. When I look out there it makes me glad I'm not you. I've experiments to be run. There is research to be done On the people who are still alive. -- Jonathan Coulton, "Still Alive"