sub add { my $a_ref2 = shift; $$a_ref2{modified}++; # (update: I forgot to include this step) foreach (keys %$a_ref2) { print $_ . " " . $$a_ref2{$_} . "\n"; } }