dirtdog has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to define and deref hash of hash of hash
by kcott (Archbishop) on Feb 07, 2017 at 19:53 UTC | |
by dirtdog (Monk) on Feb 07, 2017 at 20:51 UTC | |
|
Re: How to define and deref hash of hash of hash
by stevieb (Canon) on Feb 07, 2017 at 19:40 UTC | |
|
Re: How to define and deref hash of hash of hash
by 1nickt (Canon) on Feb 07, 2017 at 20:32 UTC | |
by Marshall (Canon) on Feb 09, 2017 at 01:35 UTC | |
|
Re: [OT] How to define and deref hash of hash of hash
by AnomalousMonk (Archbishop) on Feb 07, 2017 at 23:33 UTC | |
|
Re: How to define and deref hash of hash of hash
by NetWallah (Canon) on Feb 09, 2017 at 02:19 UTC |