Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^8: Iterating over hash while deleting elements (Best Practice)

by LanX (Archbishop)
on Feb 07, 2020 at 14:23 UTC ( #11112566=note: print w/replies, xml ) Need Help??


in reply to Re^7: Iterating over hash while deleting elements (Best Practice)
in thread Iterating over an hash while removing keys

> What's wrong with getting a new iterator as long as the function is documented to reset it?

My approach is more generic because you don't need to delete the whole hash.

You could probably also use a simple for loop and just next if the key doesn't exist anymore.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re^8: Iterating over hash while deleting elements (Best Practice)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11112566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2020-05-31 11:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (173 votes). Check out past polls.

    Notices?