I just realised that is not what OP is looking for...
There is the hard way...
use strict;
use Data::Dumper;
while (<DATA>)
{
chomp;
my @rec;
foreach (split /"(.*?)(?:(?<!")"(?!")|(?<="")"(?!"))|,/)
{ s/""/"/g, push @rec, $_ if $_ }
print Dumper(\@rec);
}
__DATA__
1,"Hello, world",This is good,2
121212,"Simpson, Bart",Springfield,"Roger"
121212,"2"" tape, ""white",springfield,"Roger"
121212,"Simpson "", Bart",Springfield,"Roger"
121212,"2""",springfield,"Roger"
And there is the easy way...
use Text::CSV_XS;
use Data::Dumper;
my $csv = Text::CSV_XS->new();
while (<DATA>)
{
chomp;
my $status = $csv->parse($_);
my @rec = $csv->fields();
print Dumper(\@rec);
}
__DATA__
1,"Hello, world",This is good,2
121212,"Simpson, Bart",Springfield,"Roger"
121212,"2"" tape, ""white",springfield,"Roger"
121212,"Simpson "", Bart",Springfield,"Roger"
121212,"2""",springfield,"Roger"