Perl: Textmode vs. Binary mode...
Arjen Bax
arjen.bax@cmg.nl
Thu Mar 22 00:13:00 GMT 2001
Bob Heckel [ mailto:BHeckel@excite.com ] wrote in answer to a question
from Mark Allan Young:
> Use this instead of "chomp" so that you don't have to worry about it:
>
> s/[\r\n]+$//; # remove <CR> and/or <LF> from the end of $_
I stumbled into the same problem a wile ago and tried exactly this
solution, but it didn't work. The reason is, that the $ in the RE
matches (perldoc perlre):
$ Match the end of the line (or before newline at the end)
so the line ending \n will not be removed. I ended up with
s/[\r\n]+\z//; # remove CR and/or LF at the end of $_
(and some time later replaced it with
s/\s+\z//; # remove whitespace at the end of $_
but that may not be what you want.)
HTH,
Arjen Bax
--
CMG Noord-Nederland B.V.
Sector Telecommunications & Utilities
Postbus 70237, 9704 AE Groningen
Tel. (050)52 19 500, Fax (050)52 19 504
< http://www.cmg.nl > < http://www.cmg.com >
Adding manpower to a late software project makes it later.
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list