use strict; use warnings; use Text::CSV_XS; my $csv = Text::CSV_XS->new(); # create a new object while () { my $status = $csv->parse($_); # parse a CSV string into fields my @columns = $csv->fields(); # get the parsed fields my $str = join '|', @columns; print "$str\n"; } __DATA__ a,b,c d,e,"f|g"