There are multiple approaches you could take, but to choose one, you'd have to know how you want to access your data. If you have a varying list of keys, for example, you could make a subroutine that would unravel the hashes:
my @keys = qw( kittehs weather tailflic ); my $value = unravel_hash(\%meows, @keys ); sub unravel_keys { my $ref = shift; while (@_) { my $key = shift; return undef if ! exists $ref->{$key}; $ref = $ref->{$key}; } # Ran out of keys, so $ref is the requested value return $ref; }
Of course, if you have array references mixed in, you'll have to make more complex code to check whether to reference by hash key or array index.
However, the module Data::Diver already does this for you, so you could just download and install it!
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: hashes in the Nth dimension
by roboticus
in thread hashes in the Nth dimension
by perlaintdead
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |