use strict; use warnings; use Text::ParseWords; my $line = q(a,b,"hey, you","str1, str2, str3",end); my @words = quotewords(',', 1, $line); print "$_\n" for @words; __END__ a b "hey, you" "str1, str2, str3" end