while ($s =~ /aa/g) { print "found aa at $-[0]\n"; pos($s) = $-[0] + 1; }