local *nums; our @nums; $x =~ / \s (?: [^\s\d]* (\d+) (?{ push(@nums, $1) }) )* /x; #### local *nums; our @nums; $x =~ / ^ (?> \S* \s ) \S*? (? \d+ ) ) (?{ push(@nums, $1) }) (?!) /x;