$s = 'a,b,"hey, you","str1, str2, str3",end'; push @fields, $1 while $s =~ /("[^"]+"|[^",]+)(?:,|$)/g; print "$_\n" for @fields; #### $s = 'a,b,"hey, you","str1, str2, str3",end'; @fields = $s =~ /("[^"]+"|[^,]+)(?:,|$)/g; # Use +, not *, or you get a blank element print "$_\n" for @fields; #### a b "hey, you" "str1, str2, str3" end