in reply to position of the last match in RE

In order for pos to remain set, you need to use the /g modifier on the regex. This is why the snippet with the while loop works. So, just use /g without the while loop:
$_ = "abcdmefg"; if ($_ =~ /m/g) { print "matched 'm' at ",pos,"\n"; }
However, if you're just looking for fixed substrings, you may prefer to use index instead:
$_ = "abcdmefg"; if (($pos = index($_, 'm')) >= 0) { print "found 'm' at ", $pos, "\n"; }
Keep in mind that pos returns the location where the previous match ended, while index returns the location where the substring begins. Thus, these two snippets give 5 and 4 respectively.