#!perl -w my $columncount; while (<>) { print "Line $. has invalid quotes: $_" if (/[^,]"[^,]/); # Let's try to fix that line automatically: s/([^,])"([^,])/$1""$2/g; my @columns = /([^",]+)|"([^"]+|"")"/g; $columncount ||= @columns; if ($columncount <> 0+@columns) { print "Line $. has weird commas and needs even more manual intervention."; }; };