>>>>> "JP" == Jeff Peng <jeffp...@netzero.net> writes:
JP> On Fri, Mar 12, 2010 at 2:21 AM, Uri Guttman <u...@stemsystems.com> wrote: >> empty lines (a single newline) is always true. the defined case only >> handles the odd trailing partial line with just '0' in it. it is the >> only way a <> without defined would lose some data as it is false. >> JP> No. Even having just 0 in a line won't make the line lost without defined. JP> $ perl -e 'print "1\n2\n3\n0"' > a.txt JP> $ perl -e 'open FD,"a.txt"; while(my $line=<FD>) { print $line }' JP> 1 JP> 2 JP> 3 JP> 0 that is because perl is adding the defined wrapper in the while clause. see other posts showing this with deparse. try your code like this: while( 1 ) { my $line = <FD> ; last unless $line ; print $line ; } that will not have an implied check for defined and the 0 line won't print. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/