my $q_str = qr("[^"]*"); # quoted string my $unq_nc_str = qr([^",]+); # string with no quotes or commas my $esc_com = qr(\\\\,); # escaped comma my @bits = grep {$_ ne ','} split /((?:$q_str|$unq_nc_str|$esc_com)+)/, $line;