It may help you to know that this doesn't work with previous versions of ActivePerl either. So I guess that you are mis-remembering the previous behaviour. ;-)

The problem is that there is no \r in the line that perl sees since it is stripped off by the Windows IO libraries. Therefore you can't remove it. And when the line is written back out the \n is replaced with \r\n (again by the IO libraries) so the \r is still in the output file.

You can convince yourself of this with the following one-liner which won't print out any of the lines in file.

perl -ne "print if /\r/" file.txt
The following will work when directed to another file:
perl -pe "BEGIN{binmode *STDOUT}" file.txt > file2.txt

This won't work with -i however, probably due to where the binmode occurs in relation to other internal actions on the input and back-up file.

--
John.


In reply to Re: Perl line endings: something broken in ActiveState Perl 5.8? by jmcnamara
in thread Perl line endings: something broken in ActiveState Perl 5.8? by rduke15

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.