in reply to Accessing this array ref.

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):

$results->{$transactionType}{$purchasedThing} += $amountSpent
or some such like that.

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, ); } }

Replies are listed 'Best First'.
Re^2: Accessing this array ref.
by Anonymous Monk on Apr 03, 2013 at 18:57 UTC
    your explanation makes sense, still having problems, I can print the first item from the array like this:
    print $results->[0];
    But running your code is giving me": Not a HASH reference".

      It sounds like you're defining $results somewhere that you haven't shown, and making it an array ref.

      As I understand it, you want results to be a hash of hashes, so just declare it as my $results; or my $results = {};