in reply to Unable to remove the ^M character

Why do you think it's a problem to get CRLF for line endings in Windows?

You're having problems removing the CR chars because they are automatically removed when the file is read and automatically re-added when the file is written. That's what DOS and Windows applications do.

I don't know if Tie::File has an option to treat the file as binary — it's kind of silly for a module that deals with lines — but you'd normally use binmode to disable this behaviour.