When a pattern is compiled, all the captures are allocated fixed indices: so for example when the following pattern is compiled, the indices shown are assigned.
/(....)...(...)...(??{foo()})....(...)/
^ ^ ^
1 2 3
In particular, the last capture is index number 3.
Each time the pattern is run, foo() might return a string or qr// which has a different number of captures; and which might recursively also include /(??{...})/ and further nested captures. This would make it nearly impossible to
guess how to refer to the final capture in the outer pattern, unless we just always call it $3.
Dave.