in reply to Having trouble reading in a hash from a referenced array
$VAR1->{movie_results}[0]{vote_average} because the value of movie_results is an array of hashes.
$VAR1 = { ... 'movie_results' => [ { ... 'vote_average' => '6.8', ...
see perldsc about nested data structures,
I suppose you can have multiple results for the same query, that's why it's an AoH.
And if you just wanna have the AoH try
my $a_movie_results = $VAR1->{"movie_results"}; as a array_ref
or expanded to a list
my @movie_results = @{$VAR1->{"movie_results"}}; as an array
likewise:
my $h_first_result = $VAR1->{"movie_results"}[0]; as a hash_ref
or expanded to a list
my %first_result = %{ $VAR1->{"movie_results"}[0] }; as a hash
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Having trouble reading in a hash from a referenced array
by bliako (Abbot) on Dec 18, 2020 at 22:54 UTC | |
by LanX (Saint) on Dec 18, 2020 at 23:10 UTC | |
by bliako (Abbot) on Dec 18, 2020 at 23:24 UTC | |
by jo37 (Curate) on Dec 19, 2020 at 14:09 UTC | |
by LanX (Saint) on Dec 19, 2020 at 01:04 UTC | |
by LanX (Saint) on Dec 19, 2020 at 01:41 UTC |