title: How can I grab multiple records from a MySQL query in Perl using array pointers?
body: <p>I can do this all as one function, but in trying to port it over to my packages of functions (library) I am missing something.</p>
  
  <p>Here's what I want to do from my main Perl script</p>
  
  <pre><code>my @rows;
  $result = Funx::dbcdata($myConnection, 
            "SELECT * FROM Inv where name like \"%DOG%\";", \@rows);
  </code></pre>
  
  <p>Then in my library package I am attempting this</p>
  
  <pre><code>sub dbcdata
  {
      my ($connection, $command, $array) = @_;
  
      my $query = $connection-&gt;prepare($command);
      my $result = $query-&gt;execute();
  
      my $i =0;
      while(my $row = $query-&gt;fetchrow_arrayref() )
      {
      @{$array}[$i] = $row;
      $i++;
      }
      $query-&gt;finish;
      return $result;
  }
  </code></pre>
  
  <p>I was hoping to get back pointers or references to each row (which was 4in this case) but am not.  Every element in @rows is the same:</p>
  
  <blockquote>
    <p>ARRAY(0x5577a0f77ec0) ARRAY(0x5577a0f77ec0) ARRAY(0x5577a0f77ec0)
    ARRAY(0x5577a0f77ec0)</p>
  </blockquote>
  
  <p>Nor do I know how to turn each one into the original separate row.  Any help would be appreciated, thanks.</p>