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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Refer by relative way to regex group (eg. the last one)
by LanX (Saint) on Jan 19, 2022 at 17:14 UTC |
In Section
Seekers of Perl Wisdom