title: Perl: Changing values of a dynamic array reference
body: <p>Assume you have:</p>
  
  <pre><code>my $data1 = [
    +{ id =&gt; 1, name =&gt; 'A' },
    +{ id =&gt; 2, name =&gt; 'B' },
    +{ id =&gt; 3, name =&gt; 'C' },
    +{ id =&gt; 4, name =&gt; 'A' },
    # .... many rows
  ];
  </code></pre>
  
  <p>as input. </p>
  
  <p>I want to change id to 1 (id =>1 ) every time name is 'A'(name => 'A'). Is a loop totally necessary?</p>
  
  <pre><code>    #  loop
  
      if ( $data1-&gt;[#what to put here?]-&gt;{id} = 1 ) {
          $data1-&gt;[#what to put here?]-&gt;{name} = 'A';
      }
  </code></pre>
  
  <p>How to do this?</p>