http://www.perlmonks.org?node_id=993865


in reply to Identifying the position of match using regular expressions

if you are using the /g modifier in your regex, you can use pos($string) to get the position after the match.
generally you can use the @- and @+ arrays to get all match offsets and ends.
my $s = "ABCDFEFFAA"; $s =~ m/AA/; say "$-[0] $+[0]"; __END__ 8 10
see perlvar