Hello monks,

What are the pros and cons of using multidimensional hash emulation compared to using hash of hashes?

Consider the following code:

%the_hash = ( empl_john_id => 13, empl_john_position => slave, empl_bob_id => 0, empl_bob_position => manager, client_fred_id => 2, client_fred_phone => 12345, client_goldman_id => 0, client_goldman_phone => 666 ); %the_hash2 = ( empl => { john => { id => 13, position => slave }, bob => { id => 0, position => manager } }, client => { fred => { id => 2, phone => 12345 }, goldman => { id => 0, phone => 666 } } }

Will %the_hash2 work faster for fetch/store operations.

Is there a generalized rule on this TIMTOWDI?

Thanks


In reply to multidimensional hash emulation vs hash of hashes by dexahex

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.