$s = 'aaa,bbb,"ccc, ddd", fff'; print join '|', $s =~ m[("[^"]+"|[^,]+)]g; aaa|bbb|"ccc, ddd"| fff