On 14 May 2012 02:17, Michael G Schwern <[email protected]> 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) {
}
Which I think would be sane. You could even pass the iterator without
passing the hash itself. (Preventing modifications to the hash but
allowing 3rd party code to iterate it).
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"