sub dequote { my ($s) = @_; $s =~ s/\\(.)/$1/g; return $s; } push @matches, defined($1) ? $1 : dequote($2) while /(?: (\d+) | (?:"(.+?)") ) /gx;