[prev in list] [next in list] [prev in thread] [next in thread]
List: perl5-porters
Subject: RE: [purl #36417] IO::Handle::getline() doco should note an impor
From: Robin Barker <Robin.Barker () npl ! co ! uk>
Date: 2005-06-29 12:34:11
Message-ID: 533D273D4014D411AB1D00062938C4D90849C6FF () hotel ! npl ! co ! uk
[Download RAW message or body]
-----Original Message-----
From: Michael G Schwern [mailto:schwern@pobox.com]
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 schwern@pobox.com 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
-------------------------------------------------------------------
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic