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

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

Thread Previous | Thread Next
From:
M.J.T. Guy
Date:
November 19, 1999 08:34
Subject:
Re: [ID 19991119.003] chomp() can be confusing
Message ID:
E11oqzg-0007iA-00@taurus.cus.cam.ac.uk
Ben_Tilly@trepp.com wrote
> Is there any possibility of having Perl's chomp() command be modified to
> recognize \n, \r, and \r\n as line-endings to chomp?

I hope not.    chomp() should match the string in $?, no more or less.

Your problem is not with chomp().   Rather it is with the I/O subsystem.
If you are reading a file as a newline-terminated text file, then
what your Perl code should see is "\n" and nothing else.

You can achieve this with tied filehandles, but I understand that
isn't what you're looking for.

I think the "right" way of doing this is by providing some sort of
filter apparatus on files.    Things of this sort were discussed in
the context of unicode.    I don't recall where (if anywhere) that
ended.


Mike Guy

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