See also the 2008 thread Finding match offsets of named captures in 5.10 regex, in which it is suggested that a code block can be used to capture the offset with a call to pos.
Update: An example:
2:56 >perl -Mstrict -wE "my $s = q[My 25 cents.]; my ($p, $q); $s =~ +/(?<myref>(?{$p = pos})\d+(?{$q = pos}))/; say $+{myref}; say $p, q[ +--> ], $q;" 25 3 --> 5 2:56 >
Athanasius <°(((>< contra mundum
In reply to Re: offset of named capture buffer
by Athanasius
in thread offset of named capture buffer
by mhgoeschl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |