title: Usage of defined with Filehandle and while Loop
body: <p>While reading a book on advanced Perl programming<sup>(1)</sup>, I came across
  this code:</p>
  
  <pre><code>while (defined($s = &lt;&gt;)) {
      ...
  </code></pre>
  
  <p>Is there  any special reason for  using <code>defined</code> here? The  <a href="http://perldoc.perl.org/perlop.html#I%2fO-Operators" rel="nofollow noreferrer">documentation for
  <em>perlop</em></a> says:</p>
  
  <blockquote>
    <p>In  these  loop  constructs,  the  assigned  value  (whether  assignment  is
    automatic or  explicit) is  then tested  to see whether  it is  defined. The
    defined test  avoids problems where  line has a  string value that  would be
    treated as  false by Perl, for  example a <code>""</code>  or a <code>"0"</code> with  no trailing
    newline. If  you really  mean for  such values to  terminate the  loop, they
    should be tested for explicitly: [...]</p>
  </blockquote>
  
  <p>So, would there be a corner case or  that's simply because the book is too old
  and the automatic <code>defined</code> test was added in a recent Perl version?</p>
  
  <hr>
  
  <p>(1)  <em>Advanced Perl  Programming, First  Edition, Sriram  Srinivasan. O'Reilly
  (1997)</em></p>