http://www.perlmonks.org?node_id=119612


in reply to Removing Carriage returns from text files

Since you are on Windows you will need to binmode() your output handle. If you don't it will automaticly add the CR to your LF every time you output a LF.
open(INFILE, "< input.txt") or die "Failed to open input: $!\n"; open(OUTFILE, "> output.txt") or die "Failed to open output: $!\n"; binmode(OUTFILE); while (<INFILE>) { print OUTFILE }
This code will remove the \r at the end of the line only. If you want to strip all \r's you will need to do s/\r//; imediatly prior to the print statment.