11.3.3. Discussion
This example prints out all keys and values from two predefined
hashes:
foreach $href ( \%ENV, \%INC ) { # OR: for $href ( \(%ENV,%INC) ) {
foreach $key ( keys %$href ) {
print "$key => $href->{$key}\n";
}
}
Access slices of hashes by reference as you'd access slices of arrays
by reference. For example:
@values = @$hash_ref{"key1", "key2", "key3"};
for $val (@$hash_ref{"key1", "key2", "key3"}) {
$val += 7; # add 7 to each value in hash slice
}