my $string = "123perl456perl789perl10"; while ($string=~m/(.{2}perl(?=(.{2})))/gp) { print "$1$2\n" }