in reply to Re: Re: To Kill a Meme: while(defined($line = <>))
in thread To Kill a Meme: while(defined($line = <>))
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: To Kill a Meme: while(defined($line = <>))
by sauoq (Abbot) on Nov 03, 2003 at 10:54 UTC | |
by Abigail-II (Bishop) on Nov 03, 2003 at 11:51 UTC | |
|
Re: Re: To Kill a Meme: while(defined($line = <>))
by sauoq (Abbot) on Nov 03, 2003 at 11:09 UTC | |
by Abigail-II (Bishop) on Nov 03, 2003 at 11:44 UTC |