I thought it was an array of hashes, but apparently, it is not. How do I access it?

It is in fact an array of hashes, but I suspect the confusion might be coming from the fact that it's a reference to an array of hashes, as indicated by the square brackets [...]. In other words, $VAR1 here is a reference to an array, and the elements of that array are the hashes. You can access it like any reference to an array, i.e. $VAR1->[0]{Lang9} is 'well'. See perldsc, perlreftut, and perlref.

Note that you haven't shown your code, but in case it looks like print Dumper(@array);, then I would guess that you're probably doing something like my @array = decode_json(...);, which isn't quite correct, as decode_json functions typically don't return an array, but instead a reference to an array or a hash. So in other words, you should be doing my $arrayref = decode_json('[...]');, and then use the dereferencing operators that are described in the links above - for example, for my $elem (@$arrayref) or my $first = $arrayref->[0];.

Edit: Added a little bit more info to first sentence.


In reply to Re: Array of hashes? by haukex
in thread Array of hashes? by Anonymous Monk

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.