in reply to hash of hashes
In your "foreach" loops, you're traversing a list of keys within the hashes and getting back just the value of those keys. Not a reference you can use directly to access the hash. To turn this into such a reference you can do like so:
my $inner = $ret->{$room};
That is, you lookup the value held in the outer hash, using the key that you're currently looping over. A complete program might look like this:
use strict; use warnings; use feature 'say'; my $ret = { room1 => { tag => 5, status => 'lazy', id => 5823 } +, room2 => { tag => 10, status => 'active', id => 1234 } +, }; for my $room ( sort keys $ret ) { say $room; my $inner = $ret->{$room}; say "\t$_ => $inner->{$_}" for sort keys $inner; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash of hashes
by NetWallah (Canon) on Apr 18, 2013 at 03:29 UTC |