G'day dirtdog,
"perldsc - Perl Data Structures Cookbook" should have all the information you need for this task.
The main problem with the code you show is the declaration and definition of hashes inside the declaration and definition of another hash.
You can write it like this:
my %teams = ( ... ); my %restaurants = ( ... ); my %Businesses = ( teams => \%teams, restaurants => \%restaurants, );
Or like this:
my $teams = { ... }; my $restaurants = { ... }; my %Businesses = ( teams => $teams, restaurants => $restaurants, );
Or like this:
my %Businesses = ( teams => { NFL => { ... }, ... }, restaurants => { FASTFOOD => { ... }, ... }, );
And various other permutations like those. See the doco I linked to for details.
You access values like this:
$Businesses{teams}{NFL}{JETS}
Again, the doco has details.
I also note all your values are just "1". That may have some significance but, if it's only to give each key some arbitrary value, you might be better off with arrays:
... NFL => [ qw{ JETS PATRIOTS GIANTS } ], ...
— Ken
In reply to Re: How to define and deref hash of hash of hash
by kcott
in thread How to define and deref hash of hash of hash
by dirtdog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |