in reply to Re: Re: To Kill a Meme: while(defined($line = <>))
in thread To Kill a Meme: while(defined($line = <>))
I'm curious by what criteria you judge that it "should have been." Do you mean that it should be there as a matter of good defensive programming style?
Nothing to do with style, but with correctness. Stuff like:
Also, the standard way of translating a while to a for(;;) loop won't work:while (($line = <>) && $line =~ /\S/) { ... } while (($line1 = <>) && ($line2 = <>)) { ... }
And even:for (;$line = <>;) { ... }
next unless $line = <>;
They are all cases where a defined test should be used, because otherwise you may get unwanted effects.
Abigail
|
|---|