use strict; use Text::ParseWords; my $string = 'one "two and a half" "three" four "five" "six"'; my @words = &parse_line('\s+', 1, $string); my $error = length($string) && @words == 0; my @unquoted = grep {!m/"/} @words; my @quoted = grep {s/^"(.*)"$/$1/} @words; print join('|', @unquoted)."\n"; print join('|', @quoted)."\n"; print $error;