Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I do a lot of work in Windows (Cygwin), macOS, and Linux, and I have a Subversion repository containing a bunch of dotfiles I use on all three platforms. As a result I do, in fact, wind up getting a nice healthy mix of CRLF and LF line endings in all environments I work in. Because of that, $/ = "\r\n"; won't work. Also, I can confirm that chomp in Cygwin perl will only remove \n from lines in text files with CRLF line endings ($/ is \n by default). I just now learned about \R which *will* do the trick: s{\R\z}{};As an added bonus it will also work with old Macintosh line endings (\r)! I honestly don't know why chomp doesn't do this in the year of our lord two thousand eighteen, other than backward combatibility. In reply to Re: Why chomp() is not considering carriage-return
by dse
|
|