in reply to position of the last match in RE

The while part isn't what sets pos, it's the /g modifier on a match. Simply say:
$_ = "abcdmefg"; m/m/g; print "Matched 'm' at ", pos, "\n";
If you don't need to match a full regex, you can use the index or rindex functions.