title: Looping through JSON data and printing out a field using Perl (Not a HASH ref)
body: <p>I need to loop through several jsons and print out index 1 of each...</p>
  
  <p>I start with a generated string containing my JSON data. I then decode the string and dump it to show exactly what I'm working with:</p>
  
  <pre><code>my $decoded = decode_json $string
  print Dumper $string
  </code></pre>
  
  <p>This results in the following output:</p>
  
  <pre><code>$VAR1 = [
        {
          'hdr' =&gt; [
                     1,
                     'acknowledged',
                     '',
                     '/home/clanier/dev/test/sds-test/data/JPLIDR2015169.64575',
                     '2015/271-19:10:39.0101355',
                     '2015/271-19:10:39.2599252',
                     ''
                   ]
        },
        {
          'hdr' =&gt; [
                     2,
                     'acknowledged',
                     '',
                     '/home/clanier/dev/test/sds-test/data/JPLIDR2015169.64575',
                     '2015/271-19:10:39.3928414',
                     '2015/271-19:10:39.6397269',
                     ''
                   ]
        },
        {
          'hdr' =&gt; [
                     3,
                     'acknowledged',
                     '',
                     '/home/clanier/dev/test/sds-test/data/JPLIDR2015169.64575',
                     '2015/271-19:10:39.7726375',
                     '2015/271-19:10:40.0162758',
                     ''
                   ]
        }
      ];
  </code></pre>
  
  <p>Now I try to loop through this and print the word acknowledged for each one:</p>
  
  <pre><code>foreach my $hdr ( $decoded-&gt;{hdr} ) {
    print $hdr-&gt;[1];
  }
  </code></pre>
  
  <p>I looked to <a href="https://stackoverflow.com/questions/8258387/accessing-values-of-json-structure-in-perl">this solution</a> for help, but it appears I cannot even get as far as the original poster, due to "Not a HASH reference" errors. I was able to print a specific one previously, but I need to loop through and print all of them. This was the code for that: <code>print $$decoded[0]-&gt;{'hdr'}-&gt;[1];</code></p>