in reply to Refer by relative way to regex group (eg. the last one)
You do not say how your code fails, but if you add use strict; to your example you get
$ perl -Mstrict -Mwarnings -e 'my $word; "foobar" =~ /(oo)(bar)(?{$word=${-1}})/' Can't use string ("-1") as a SCALAR ref while "strict refs" in use at -e line 1.
Suggestions:
$ perldoc -v '@-' $ perldoc -v '@+'
Or, under at least Perl 5.10, you could use named captures.
In Section
Seekers of Perl Wisdom