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

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

Thread Previous | Thread Next
M.J.T. Guy
November 19, 1999 08:34
Re: [ID 19991119.003] chomp() can be confusing
Message ID: 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

Mike Guy

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About