Hi Monks,

I'm having trouble finding out how to define a hash of hash of hashes ( I think this is what I want). I just have some hashes of hashes and I realized that I need to pass a parameter to determine which hash of hash i'll be using. Therefore, I thought the hash of hash of hash would be the best solution.

my %Businesses = ( my %teams = ( NFL => { 'JETS' => 1, 'PATRIOTS' => 1, 'GIANTS' => 1 }, MLB => { 'YANKEES' => 1, 'METS' => 1, 'CARDINALS' => 1 }, NBA => { 'SIXERS' => 1, 'CELTICS' => 1, 'LAKERS' => 1 }, ); my %restaurants = ( FASTFOOD => { 'WENDYS' => 1, 'MCDONALDS' => 1, 'BURGER KIN +G' => 1 }, FINEDINING => { 'GRILL 23' => 1, 'CAPITAL GRILL' => 1, 'MO +RTONS' => 1 }, MIDRANGE => { 'OUTBACK' => 1, 'TEXAS ROADHOUSE' => 1, 'CH +ILIS' => 1 }, ); );

If the parameter passed in was "teams" then I would use a for loop to dereference teams, but if the parm was restaurants then I'd dereference those.

CAn someone please let me know how to define the hash of hash of hashes? and then dereference them? Thank you very much for taking the time


In reply to How to define and deref hash of hash of hash by dirtdog

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.