use strict; use warnings; use Data::Dumper; 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 print Dumper(\@columns); } __DATA__ aa,bb,cc 0,2,3