The problem is that you're reading line by line, and not record by record, and you have no solid detection of when a record is continued on the next line.
I think that Text::CSV has a solution for that, you might need to tweak some of the options though.