"Cornish, Merrill" wrote:
> Also beware: while(<FILE>) will stop reading if it hits an empty line in
> the middle of the file because an empty string counts as "false" in a Perl
> boolean compare. A safer way is
>
> while(defined($line = <FILE>))
>
> so that only the end-of-file will cause you to break out of the loop.
That's not correct. Look at how the "while (<FILE>)" construct is
parsed:
$ perl -MO=Deparse -e "open FILE, 'xyz'; while (<FILE>) { }"
open FILE, 'xyz';
while (defined($_ = <FILE>)) {
();
}
As you can see,
while (<FILE>)
is equivalent to
while (defined($_ = <FILE>))
Quite a lot of perl code would break if this construct broke on empty
records.
--
Ned Konz
currently: Stanwood, WA
email: [EMAIL PROTECTED]
homepage: http://bike-nomad.com, Perl homepage:
http://bike-nomad.com/perl
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]