$_ = qq(item1,field2,more data,"a quoted, comma containing string"\n); @data = /(\".*?\"|.*?)[\n,]/g; $j = 0; printf "%d: %s\", $j++, $_ for @data;