Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: OT: clearing a hash (was: TIMTOWTDI doesn't mean invent an outlandish approach (usually))

by Abigail-II (Bishop)
on Oct 13, 2003 at 11:36 UTC ( [id://298810]=note: print w/replies, xml ) Need Help??


in reply to Re^2: OT: clearing a hash
in thread TIMTOWTDI doesn't mean invent an outlandish approach (usually)

Number 1) is safe because in this case, a list of keys will be produced before the deletes are called. For 3) and 4), I though that 'for (keys %hash)' was special cased to iterate over the hash instead of producing a list (just like 'for (@array)' is special cased), but I can't find it in the documentation right now. Anyway, regardless whether it's special cased or not, 3) and 4) are fine as well, due to the exception of modifying a hash while iterating over it by deleting the last element returned by 'each' (since 'keys' and 'values' uses the same iterator).

Abigail

  • Comment on Re: OT: clearing a hash (was: TIMTOWTDI doesn't mean invent an outlandish approach (usually))

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-19 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found