print(Dumper(@array)); -> print(Dumper(\@array));
print(Dumper(%hash)); -> print(Dumper(\%hash));
print(Dumper($a_ref)); -> ok
print(Dumper($h_ref)); -> ok
####
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.
}
}
####
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.
}