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

Re^3: Hash of hashes assignment

by johngg (Abbot)
on Apr 12, 2013 at 22:02 UTC ( #1028454=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Hash of hashes assignment
in thread Hash of hashes assignment

The "2/8" of a hash in scalar context is just a representation of the number of "buckets" used/assigned for the hash. Note that more than one key can be assigned to the same "bucket" depending on how the hashing algorith works on the keys involved and that keys can be redistributed when more "buckets" are assigned as the hash grows.

$ perl -Mstrict -Mwarnings -E ' > my %hash; > say scalar %hash; > for ( q{a} .. q{z} ) > { > $hash{ $_ } = 1; > say qq{$_ - @{ [ scalar %hash ] }}; > }' 0 a - 1/8 b - 2/8 c - 3/8 d - 4/8 e - 5/8 f - 6/8 g - 6/8 h - 7/16 i - 8/16 j - 9/16 k - 9/16 l - 10/16 m - 10/16 n - 11/16 o - 11/16 p - 14/32 q - 14/32 r - 14/32 s - 15/32 t - 15/32 u - 16/32 v - 16/32 w - 17/32 x - 17/32 y - 18/32 z - 19/32 $

I hope this is helpful.

Cheers,

JohnGG


Comment on Re^3: Hash of hashes assignment
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-09-17 21:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (99 votes), past polls