in reply to Re: Changing CRLF in Windows to LF for UNIX
in thread Changing CRLF in Windows to LF for UNIX

That worked, so thanks. But now I'm trying to figure out why my code didn't work earlier. I had binmode turned on, and I thought it defaulted to ":raw", and indeed that's what allowed me to get the Macintosh CR to show up solo at the end of each line. I did try to explicitly add ":raw" to the end, but that didn't help.
  • Comment on Re^2: Changing CRLF in Windows to LF for UNIX

Replies are listed 'Best First'.
Re^3: Changing CRLF in Windows to LF for UNIX
by choroba (Cardinal) on Oct 30, 2018 at 21:07 UTC
    Have you tried binmoding the OUT, too?

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      That was indeed my problem. There's nothing like fixing the problem, then unfixing it ...
Re^3: Changing CRLF in Windows to LF for UNIX
by pwagyi (Monk) on Nov 02, 2018 at 08:36 UTC

    You should use 3 arg open FILEHANDLE,MODE,EXPR. I tried out the code and it does work for me.

    >> I'm coding in Windows (Windows 10) and trying to change a Windows created text file that ends in CRLF to just LF, so that I can upload the file and process it on a Unix-based site.

    If you are running the script in Windows, it will happen since when you open for write (without binmode or :raw or :unix), Perl will perform '\n' to (Windows) platform '\r\n'.