But, then again...
The Text::ParseWords module is certainly powerful, but I can't seem to make it handle errors very well. It does not like "John said "Hello"","again"
So I went back to my earlier method with a better regex
undef $/;
my $infile = (<>);
my @fields = $infile =~ /(".*?"(?=,|\n)|\n)/gms;
my $place = "\n";
foreach (@fields) {
if ($place ne "\n" && $_ ne "\n") {print ",";};
unless ($_ eq "\n") {s/\n//g;};
print "$_";
$place = $_;
}
|