From kragen@dnaco.net Wed Aug 26 12:30:39 1998 Date: Wed, 26 Aug 1998 12:30:37 -0400 (EDT) From: Kragen To: Kragen cc: "Bradley M. Kuhn" , clug-user@clug.org Subject: Re: another way to do it (was Re: Web Page Help) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Keywords: X-UID: 1457 Status: O X-Status: On Wed, 26 Aug 1998, Kragen wrote: > On Wed, 26 Aug 1998, Bradley M. Kuhn wrote: > > Thus spoke Kragen: > > > while (<>) { > > > > ARGH! Why not use: > > while ( defined(my $line = <>)) > > It handles the zero byte problem gracefully. :) > > Why not? Because I'd never heard of the zero byte problem. > > Are you saying that the string "\0" is false as a boolean? Maybe we > should fix this problem here. print "yes" if "\0"; print "no" if not "\0"; print "\n"; yields "yes" in Perl 5.003 and 5.004_04. Perhaps you're referring to something else? Like when the line after the last newline has no bytes in it? (My program handles that by not printing any bytes after the last newline it prints.) Ohh! Maybe you're referring to the case where the last line in the file is unterminated and says something like "0"? That seems like it ought to cause a problem. Here I try it with Perl 5.004_04: > cat perlprog while (<>) { print; } __END__ 0> perl perlprog perlprog while (<>) { print; } __END__ 0> Hmm, it seems to have worked. I can't see how, but it did. OK, you've got me curious. What's the zero-byte problem?! Kragen -- Kragen Sitaker We are forming cells within a global brain and we are excited that we might start to think collectively. What becomes of us still hangs crucially on how we think individually. -- Tim Berners-Lee, inventor of the Web