note
dse
<p>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, <tt>$/ = "\r\n";</tt> won't work.</p>
<p>Also, I can confirm that <tt>chomp</tt> in Cygwin perl will only remove <tt>\n</tt> from lines in text files with CRLF line endings (<tt>$/</tt> is <tt>\n</tt> by default).</p>
<p>I just now learned about <tt>\R</tt> which *will* do the trick:</p>
<code>s{\R\z}{};</code>
<p>As an added bonus it will also work with old Macintosh line endings (<tt>\r</tt>)!</p>
<p>I honestly don't know why <tt>chomp</tt> doesn't do this in the year of our lord two thousand eighteen, other than backward combatibility.</p>
549385
549385