title: How to reread perl database query result
body: <p>I would like to use the results of a query twice.<br>
  How do I reposition the pointer to start reading the results from the beginning a second time?<br>
  Example below (just printing to screen for simplicity):  </p>
  
  <pre><code>if ( $dbh = DBI-&gt;connect( "DBI:mysql:database=tng;host=ip", "username", "password" ) ) {
      $strSQL = "select * from table";
      if ( $strQuery = $dbh-&gt;prepare($strSQL) ) {
          if ( $strQuery-&gt;execute() ) {
              while ( @data = $strQuery-&gt;fetchrow_array() ) {
                  print $data[0];
              }
              --reposition to top and reread the query result and do something else with the data-- $strQuery-&gt;finish;
          }
          else {
              $strMsg = "$strDateTime ERROR -- unable to execute statement: " . $strQuery-&gt;errstr . "\n";
              print logFile "$strMsg";
          }
      }
      else {
          $strMsg = "$strDateTime ERROR -- unable to prepare statement: " . $dbh-&gt;errstr . "\n";
          print logFile "$strMsg";
      }
      $dbh-&gt;disconnect();
  }
  else {
      print logFile "$strDateTime ERROR -- unable to connect to iptables database ... " . DBI-&gt;errstr . " \n";
  }
  </code></pre>