Alex Rivera | Logout

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

Asked 2009-03-16T14:48:16.647
39

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?

Edit
Report

1 Answer

3

This one liner replaces all the ^M characters:

dos2unix <file-name>

You can call this from inside Perl or directly on your Unix prompt.

answered 2012-08-03T23:04:29.990

Your Answer