This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Perl: Textmode vs. Binary mode...


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]