Howdy mitch, welcome back to the Monastery!
You're almost right. It's several hashes in an array indeed, but $data->{'results'} is itself an array reference, so in your example, @result is a one-element list (i.e. array) containing a single reference to an anonymous array containing several anonymous hashes.
In order to iterate through all these, your best bet is to dereference the outermost array reference, obtaining the array of hashes again, then iterating through its elements (the hashes) and looking at each hash's closed_at key, like this:
... my $result_ref = $data->{'results'}; my @result = @$result_ref; foreach my $hash_ref (@result) { say "closed_at: ", $hash_ref->{'closed_at'}; ... }
Of course, you don't have to save $result_ref and @result unless you need them. The foreach loop could also be written this way:
... foreach my $hash_ref (@{ $data->{'results'} }) { ... }
The result's the same, but the above will perhaps make it a little more clear what's going on.
In reply to Re: hash-array-hash confused
by AppleFritter
in thread hash-array-hash confused
by mitchreward
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |