in reply to Re: To Kill a Meme: while(defined($line = <>))
in thread To Kill a Meme: while(defined($line = <>))
One minor nit: You missed a way to get a false-but-defined value. It's possible if you've set $/=\1, that is, if you're reading a byte at a time.One minor nit: that won't work, I quote perldoc perlop
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 "" or a "0" with no trailing newline. If you really mean for such values to terminate the loop, they should be tested for explicitly:You can test if you need convincing ;)
update:E:\>perl $|=1; $/=\1; print "[$_]" while <>; __END__ abcd [a][b][c][d][ ]0000000000000 [0][0][0][0][0][0][0][0][0][0][0][0][0][ ]^Z
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: To Kill a Meme: while(defined($line = <>))
by sauoq (Abbot) on Nov 03, 2003 at 07:53 UTC | |
|
Re: Re: Re: To Kill a Meme: while(defined($line = <>))
by theorbtwo (Prior) on Nov 03, 2003 at 07:52 UTC |