I prefer to use references all the way down, it reads better to me this way.
my $array_ref = [
{ foo=> 1, herp => 'a'},
{ bar => 2, derp => 'b'},
{ baz => 3, burp => 'c'},
];
# to iterate
foreach my $h (@$array_ref) {
foreach $k (keys %$h) {
++$h->{$k}; # note ++ "increments" strings as well
}
}
Or in a more direct way.
my $array_ref = [
{ foo=> 1, herp => 'a'},
{ bar => 2, derp => 'b'},
{ baz => 3, burp => 'c'},
];
# unrolled iteration loop
++$array_ref->[0]->{foo}; # now 2
++$array_ref->[0]->{herp}; # now b
++$array_ref->[1]->{bar}; # now 3
++$array_ref->[1]->{derp}; # now c
++$array_ref->[2]->{baz}; # now 4
++$array_ref->[2]->{burp}; # now d
|