in reply to Re^3: Remove CR from file on Windows
in thread Remove CR from file on Windows
You think your solution works because your script to create the test file and your script to dump the test file suffers from the same bug as your solution. Your demonstration only shows that you can convert CRCRLF to CRLF.
The first f.txt contains foo\r\r\nbar\r\r\nstuff.
>perl -e "print \"foo\r\nbar\r\nstuff\";" > f.txt >debug f.txt -rcx CX 0011 : -d100 l11 0AF7:0100 66 6F 6F 0D 0D 0A 62 61-72 0D 0D 0A 73 74 75 66 foo...bar +...stuf 0AF7:0110 66 f -q
You alter it to foo\r\nbar\r\nstuff.
>perl -i.bak -pe "s/\r(?=\n)//" f.txt >debug f.txt -rcx CX 000F : -d100 lf 0AF7:0100 66 6F 6F 0D 0A 62 61 72-0D 0A 73 74 75 66 66 foo..bar. +.stuff -q
why doesn't it work??
Unless you use binmode on your input file, CRLF gets converted to LF on read.
Unless you use binmode on your output file, LF gets converted to CRLF on write.
|
|---|