Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by LanX (Saint)
on Feb 07, 2020 at 14:23 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11112566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-23 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found