Search code examples
perlcarriage-returnhidden-characters

In Perl, how to remove ^M from a file?


I have a script that is appending new fields to an existing CSV, however ^M characters are appearing at the end of the old lines so the new fields end up on a new row instead of the same one. How do I remove ^M characters from a CSV file using Perl?


Solution

  • You found out you can also do this:

    $line=~ tr/\015//d;