Dear Perl Monks,

I am running into a wall when I use TMDB's

my @results = $search->find( id => 'tt0114694', source => 'imdb_id' );

The result I get back is a hash that comes back in a referenced array. in my case it's just one item returned, which is posted at the bottom. When I read the fifth key in the hash, I get an array. I am assumed that it is also an array of another hash. Obviously it is not, and there is where I am stuck.

When I use this code, I get the same array for both. If someone can tell me what I am getting wrong, I'd appreciate it so much.

foreach my $narray (@results){ print $narray->{"movie_results"}; print "\n"; my @newarray = $narray->{"movie_results"}; print $newarray[0]; print "\n";

This is my output from the original call

$VAR1 = { 'tv_season_results' => [], 'tv_results' => [], 'person_results' => [], 'tv_episode_results' => [], 'movie_results' => [ { 'adult' => bless( do{\(my $o = 0) +}, 'JSON::PP::Boolean' ), 'vote_average' => '6.8', 'original_title' => 'Tommy Boy', 'vote_count' => 635, 'id' => 11381, 'release_date' => '1995-03-31', 'overview' => 'Party animal Tommy + Callahan is a few cans short of a six-pack. But when the family busi +ness starts tanking, it\'s up to Tommy and number-cruncher Richard Ha +yden to save the day.', 'genre_ids' => [ 35 ], 'title' => 'Tommy Boy', 'video' => $VAR1->{'movie_results +'}[0]{'adult'}, 'poster_path' => '/g32WbO9nbY5ydp +ux5hIoiJkLEQi.jpg', 'original_language' => 'en', 'backdrop_path' => '/bZ4diYf7oyDV +aRYeWG42Oify2mB.jpg', 'popularity' => '13.945' } ] };


In reply to Having trouble reading in a hash from a referenced array by SergioQ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.