for my $hashRef ( @$my_array_ref ) # Curlies aren't needed here since $my_array_ref is a simple variable name { ... } #### $results->{$transactionType}{$purchasedThing} += $amountSpent #### for my $transactionType (sort keys %$results) { for my $purchasedThings (sort keys %{ $results->{$transactionType} }) # Curlies here to mark out what to dereference { printf("spent \$%5d on %20s using %20s\n", $results->{$transactionType}{$purchasedThings}, $purchasedThings, $transactionType, ); } }