You have an array reference. Each element of the array is a hash reference.
So, when you loop, you are doing:
for my $hashRef ( @$my_array_ref ) # Curlies aren't needed here since +$my_array_ref is a simple variable name { ... }
For each hash ref, you can inspect the contents via: $hashRef->{name} or $hashRef->{type} etc...
It looks like you want to spin through all the data and build a new Hash of Hashes (HoH):
or some such like that.$results->{$transactionType}{$purchasedThing} += $amountSpent
When looping through the hashes to display, you probably want to sort the keys so that you print in the same order each time.
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, ); } }
In reply to Re: Accessing this array ref.
by SuicideJunkie
in thread Accessing this array ref.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |