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 n
^M
This one liner replaces all the ^M characters:
dos2unix
You can call this from inside Perl or directly on your Unix prompt.