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