$test = "test 1 2 test 15 67 test 435 578"; while ( $content =~ /test (\d+) (\d+)/g) { say "test from $1 to $2"; }