in reply to Avoiding printing ^M to STDOUT

If those ^M's are in the source file and you're copying them from there, you'll want to use a regex to remove them; the one suggested by xorl should work fine.

If you're running on an OS like Windows that likes to put CR/LF at the end of its lines, you'll want to use binmode to tell Perl not to do that.