develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991119.003] chomp() can be confusing

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
November 21, 1999 13:33
Subject:
Re: [ID 19991119.003] chomp() can be confusing
Message ID:
199911212133.VAA03781@bactrian.ni-s.u-net.com
Tom Christiansen <tchrist@jhereg.perl.com> writes:
>>: I expect chomp() to remove one and only one terminating instance of the
>>: precise string to which $/ has been set; no more, no less.  What were
>>: you expecting?
>
>>I expect people to expect Perl to do the right thing.
>
>And that would be what, sniff around the stdio buffer the first time you
>play with it and figure out what it smells like?

That is far from daft. sv_gets() (the internals of readline) would know 
what it had used to find the end of the line. It could leave the 
information around for chomp to use.

But the "right thing" is 
just to return \n as a logical newline however it was represented in the 
buffer (unless in binmode of course). Then chomp'ing \n is fine.

>
>--tom
-- 
Nick Ing-Simmons


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About