title: parsing json file using perl
body: <p>I am trying to parse a json file in perl. I want to extract the key "name" and corresponding value of it.
  my file looks like this</p>
  
  <pre><code>{
   "data":[
      {
          "name":"ABC",
          "id":"123",
      },
      {
          "name":"PQR",
          "id":"456",
      },
      {
          "name":"XYZ",
          "id":"789",
      }
  ]
  }
  </code></pre>
  
  <p>I am trying with below code:</p>
  
  <pre><code>#/usr/lib/perl
  use lib qw( ..);
  use LWP::Simple;
  use JSON;
  my $filename = '/file.txt';
  my $data;
  if (open (my $json_str, $filename))
  {
    local $/ = undef;
    my $json = JSON-&gt;new;
    $data = $json-&gt;decode(&lt;$json_str&gt;);
    close($json_stream);
  }
  print $data-&gt;{name};
  </code></pre>
  
  <p>But I not getting any output.</p>
  
  <p>Can anyone tel me what is wrong ?</p>