title: What's the difference between iterating over a file with foreach or while in Perl?
body: <p>I have a filehandle <code>FILE</code> in Perl, and I want to iterate over all the lines in the file.  Is there a difference between the following?</p>
  
  <pre><code>while (&lt;FILE&gt;) {
      # do something
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>foreach (&lt;FILE&gt;) {
      # do something
  }
  </code></pre>