Here's how a hash works, in a nutshell... You've got a list of buckets, each of which is a list of zero or more items. You also have a hash function that converts a key into a "hash" value used to look up a bucket. (For any given key, the hash function must always return the same result; otherwise you wouldn't be able to find your items again!)

When you want to do something with a specific key, you call the hash function for that key, use the result to find the appropriate bucket, and then search all the items in that bucket for the one you want. So, instead of having to check against every item in the hash, you only have to check against a few items that happen to be in the same bucket.

As you keep adding to the hash, each bucket has to hold more items. As the buckets get bigger, the lookups get slower, because you have to search through more items. That problem is solved by dynamically increasing the number of buckets and redistributing the items as the hash grows in size.

Your hash has 64 buckets (Perl always uses a power of 2), although only 42 are being used to store the 53 items. That just means that, with that combination of hash function, number of buckets, and keys, a few of the keys are sharing buckets.


In reply to Re: Re: Re: print scalar %hash... erm by chipmunk
in thread print scalar %hash... erm by pileswasp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.