Equivalent of Perl chomp?

A Meowbot meowbot at meowing.net
Thu Jan 31 20:35:50 EST 2002


aahz at panix.com (Aahz Maruch) wrote:

> In article <86aduup3zu.fsf at k0dez.scriptkiddie.net>,
> A Meowbot  <meowbot at meowing.net> wrote:

>>Where things get yucky is when you are reading a Microsoft-formatted
>>file or a network stream under Unix, where there is no difference
>>between text and binary.  It's for those all-too-common cases that
>>both line endings need to be taken into account.
>>
>>I don't even want to talk about the Apple CR thing.
>
> How does Perl deal with this?

You can set $/ to change what string signifies an end of line, and
chomp will honor that.  This does, of course, require you to know
which line ending convention was used in the input.



More information about the Python-list mailing list