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

Re: hashes of array references

by davorg (Chancellor)
on Jul 22, 2009 at 19:19 UTC ( #782415=note: print w/ replies, xml ) Need Help??


in reply to hashes of array references

$numInHash = %$EDHRef;

This isn't doing what you think it is. Evaluating a hash in scalar context is rarely useful. They don't work the same way as arrays.

What you really want is to call keys in scalar context. That will give you the number of keys in the hash.

$numInHash = keys %$EDHRef;
--

See the Copyright notice on my home node.

Perl training courses


Comment on Re: hashes of array references
Select or Download Code
Re^2: hashes of array references
by tobyperl (Initiate) on Jul 22, 2009 at 20:24 UTC
    You are the Perl God....that was exactly my problem. Actually the code worked fine. I was just obtaining the number of elements wrong. Thank you very much.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2014-12-19 22:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (92 votes), past polls