Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
schwern opened this issue Sep 27, 2011 · 0 comments
Closed

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

schwern opened this issue Sep 27, 2011 · 0 comments

Comments

@schwern
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant