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 is what solved my problem. ^M is a carriage return, and it can be easily avoided in a Perl script.
while() { chomp; chop($_) if ($_ =~ m/\r$/); }