-----Original Message-----
From: Michael G Schwern [mailto:[EMAIL PROTECTED]
Sent: 29 June 2005 00:21
To: perl5-porters@perl.org
Subject: Re: [perl #36417] IO::Handle::getline() doco should note an
important difference from <$io>


On Tue, Jun 28, 2005 at 06:25:31PM -0000, Justin Mason wrote:
> However, there is one key difference: "while (<$io>)" and "while
> ($io->getline)" ha ve different behaviour.    If the last line of an input 
> file
> contains "0" (with no trailing newline), "while (<$io>)" will read it and
> perform an iteration of the while loop, but "while ($io->getline)" will read
> it, consider it a false value, and instead break out of the while loop.

Confirmed.  while(<FH>) must have some sort of special case to consider
"0" true to avoid this sort of gotcha.

-----

Surely bigger difference is that 
        C< while(<$io>) > sets C<$_>
while
        C< while($io->getline) > does not.

Robin

-- 
Michael G Schwern     [EMAIL PROTECTED]     http://www.pobox.com/~schwern
Just call me 'Moron Sugar'.
        http://www.somethingpositive.net/sp05182002.shtml

-------------------------------------------------------------------
This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No: 2937881
Registered Office: Serco House, 16 Bartley Wood Business Park,
                   Hook, Hampshire, United Kingdom  RG27 9UY
-------------------------------------------------------------------

Reply via email to