title: How to prematurely detect whether it's the last iteration during a while loop in Perl
body: <p>Similar question(does not solve my question): <a href="https://stackoverflow.com/questions/19390020/is-it-possible-to-detect-if-the-current-while-loop-iteration-is-the-last-in-perl">Is it possible to detect if the current while loop iteration is the last in perl?</a></p>
  
  <p>Post above has an answer which solves the issue of detecting whether it's the last iteration solely when reading from a file. </p>
  
  <p>In a while loop, is it possible to detect if the current iteration is the last one from a mysql query?</p>
  
  <pre><code>while( my($id, $name, $email) = $sth-&gt;fetchrow_array() ) 
  {
         if(this_is_last_iteration)
         {
              print "last iteration";
         }
  }
  </code></pre>