Is it really a literal caret and a literal uppercase letter m? Or is it a file that was created on Windows, and the ^M is your editors representation of the carriage return '\r'?
If it's the latter, use either dos2unix (if available) OR open the file in an editor that understands both formats and save it in UNIX format again OR run it trough tr (or similar) to remove the \r at the end.
And it's no wonder your Perl one-liner didn't do anything, it won't even run that way.
this uld automatically convert the extra characters that are viewed
in some unix version the format is
dos2unix filename1 filename2
if both the filename1 and filename2 are same it uld remove the extra characters and write in the same file filename1 else it converts and writes to filename2