print(Dumper(@array)); -> print(Dumper(\@array)); print(Dumper(%hash)); -> print(Dumper(\%hash)); print(Dumper($a_ref)); -> ok print(Dumper($h_ref)); -> ok
Now back to the question. You have an array which contains references to arrays (groups??) which contains references to hashes (cities), with key State (and key Town).
my @array = ( [ { 'State' => 'Maine', 'Town' => 'Portland' }, { 'State' => 'New Hampshire', 'Town' => 'Concord' } ], [ { 'State' => 'Florida', 'Town' => 'Jacksonville' }, { 'State' => 'North Carolina', 'Town' => 'Waynesville' } ] ); foreach my $group (@array) { # which contains refs to arrays foreach my $city (@$group) { # which contains refs to hashes print($city->{State}, "\n"); # with key State. } }
You probably wanted an AoH instead of an AoAoH.
my @array = ( { 'State' => 'Maine', 'Town' => 'Portland' }, { 'State' => 'New Hampshire', 'Town' => 'Concord' }, { 'State' => 'Florida', 'Town' => 'Jacksonville' }, { 'State' => 'North Carolina', 'Town' => 'Waynesville' } ); foreach my $city (@array) { # which contains refs to hashes print($city->{State}, "\n"); # with keys State. }
In reply to Re: printing array ref of hash refs
by ikegami
in thread printing array ref of hash refs
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |