Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by LanX (Sage)
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
Domain Nodelet?
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 musing on the Monastery: (5)
As of 2021-12-02 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (23 votes). Check out past polls.

    Notices?