Guarantee each() iterates through the entire hash. #7

schwern opened this Issue Sep 27, 2011 · 0 comments


None yet
1 participant

schwern commented Sep 27, 2011

The major problem with each() is it is vulnerable to this subtle bug...

while( my($k,$v) = each %hash ) {
    ... do something ...
    last if $k eq "Foo";

This leaves the iterator of %hash incomplete. The next loop will not iterate through the complete hash. This makes each dangerous to use.

autobox::Core can solve this by resetting the iterator.

@schwern schwern closed this in 8a0b95d Sep 27, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment