in reply to Regular expression to remove ^M

^M and \^M take on different meanings in regexen. The first looks for a capitol 'M' as the first character in the string. The second looks for literal '^M' -- two characters.

ikegami shows you several ways to do that, there are others. '\cM' is perhaps the closest to what you are trying. For portability to mac, '\r' is likely the best choice.

Instead of substitution, try transliteration,

tr/\r//d;
It's somewhat faster, and is equivalent to s/\r//g;.

After Compline,
Zaxo