$string = 'a=111a=222a=333'; for ($string =~ m/(a=\d+)/g) { print "$_\n"; # any other code }