Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Using 'each' to get random (key, value) pair from hash returns "uninitialized value"

by puterboy (Scribe)
on Jan 28, 2011 at 21:08 UTC ( #884926=note: print w/ replies, xml ) Need Help??


in reply to Re: Using 'each' to get random (key, value) pair from hash returns "uninitialized value"
in thread Using 'each' to get random (key, value) pair from hash returns "uninitialized value"

Thanks. I had actually read that sentence but had 'misunderstood' it - thinking of it only in the foreach loop context and not realizing the same thing applies in a non-loop. By the way, your analogy was really helpful.

If I am now understanding the sentence correctly, I can do something like the following:

 ($key, $value) = each %hashCache || each %hashCache;

Presumably this would 'eat' the 'undef' token and make the lazy-a** conductor go back to the front of the bus and start collecting tickets again :)


Comment on Re^2: Using 'each' to get random (key, value) pair from hash returns "uninitialized value"
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-12-27 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls