while ($string =~ /([^"]*)"([^"]*)"(.*)/g) { push @result, ((split " ", $1), $2); $string = $3; } push @result, split " ", $string if $string;