title: perl load json from file and loop
body: <p>I've got a file like this:</p>
  
  <pre><code>{
      "dev":
      {
          "data": "1"
      },
      "stg":
      {
          "data": "1"
      },
      "pre":
      {
          "data": "1"
      },
      "prod":
      {
          "data": "1"
      },
  }
  </code></pre>
  
  <p>I load the json like this:</p>
  
  <pre><code>open(FH,"&lt;",$file) or die "environments.json file doesn't exists!\n";
  my $data = &lt;FH&gt;;
  
  my $ret = JSON::decode_json( $data );
  </code></pre>
  
  <p>It loads properly, I can do:</p>
  
  <pre><code>print "Dumper: " .  Dumper($ret) . "\n";
  </code></pre>
  
  <p>But when I try to loop through it with:</p>
  
  <pre><code>foreach my $env( @$ret )
  {
      print "Environment: " . $env-&gt;{"data"} . "\n";
  }
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>Not an ARRAY reference at ./launcher.pl line 20, &lt;FH&gt; line 1.
  </code></pre>
  
  <p>On the <code>foreach my $env( @$ret )</code> line
  Help is appreciated!</p>
  
  <p>Thanks!</p>
  
  <p>David</p>