in reply to Removing the ^M character, but also removing the newline

Wouldn't you be able to do something like $formdata{$j} =~ s/[\n\r]+//gs; ?

Am I correct that this would

thus effectively removing them (as desired)? (You could also replace with a single space or something else, if preferred.)

(The other solutions presented, however, may be more correct and/or efficient, however-this was just what I threw together while reading the post. I tried testing against files I generated with lines ending in "\n", "\r", "\r\n", and "\n\r", and it appeared to work, but YMMV.)