I mostly agree with that except that I think it does lead to mistakes. Not coding mistakes, but conceptual mistakes. When it is coded explicitly, it seems to indicate that it is necessary for a common case.
Well, generally, the defined test is necessary. The "common" case is the exception where Perl is providing the short-cut. If there is any danger, it's that people get used to writing while ($line = <>), and think that they can also write: while ($cond and $line = <>) or $line = <>; while ($line) {.... ; $line = <>}.

Now, I don't think the danger is anything to worry about, but I've seen cases where the defined() test was missing where it should have been.

Now, I'd be really interested in hearing what you think is the common case, and where people get it wrong by using defined ($line = <>).

Abigail


In reply to Re: To Kill a Meme: while(defined($line = <>)) by Abigail-II
in thread To Kill a Meme: while(defined($line = <>)) by sauoq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.