in reply to Splitting a line on just commas

use Text::ParseWords; my $line = q(a,b,"hey, you","str1, str2, str3",end); @words = &quotewords(',', 0, $line);

Replies are listed 'Best First'.
Re^2: Splitting a line on just commas
by toolic (Bishop) on Jun 14, 2010 at 16:14 UTC
    ... and to preserve the quotes using Text::ParseWords, if desired:
    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