Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: number of keys and values in a hash

by JavaFan (Canon)
on Oct 12, 2011 at 06:32 UTC ( #930914=note: print w/replies, xml ) Need Help??


in reply to number of keys and values in a hash

You are calling "keys" inside the while loop where you are doing "each". Calling "keys" resets the "each" loop. Which explains the infinite loop.

As pointed out, there's no need to iterate over the hash using each. Considering you are calling keys - I've no idea why you are using each.

Furthermore, since you build the hash as a one key, one value pair, why the need to find out the number of keys? The answer to that is already known, isn't it?

  • Comment on Re: number of keys and values in a hash

Replies are listed 'Best First'.
Re^2: number of keys and values in a hash
by veerubiji (Sexton) on Oct 12, 2011 at 07:10 UTC

    hi javafan, I need to to fill my hash with all keys, still now i have only one element in hash. so i need to fill all elements in hash then disply the number of keys.

      Uhm, why don't you count them while filling in? ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-01-29 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (74 votes). Check out past polls.

    Notices?