In Perl, how to remove ^M from a file? August 11, 2023 by Tarik ^M is carriage return. You can do this: $str =~ s/\r//g