in reply to Remove CR from file on Windows

You can use binmode (FILE) to put FILE into binary mode after opening it, which should disable line end translation. You'll probably need to do this for both your input and your output files.