First page Back Continue Last page Overview Graphics
Relative refs and named capture
- my $dupew = qr/
- (?<dupe>\w+) # named capture a “word”
- \s+ # one or more spaces
- \g{-1} # relative backref
- /x;
- # note 'the' isn't a match.
- if ('the foo foo in the doo doo'=~/ $dupew .*? $dupew /x) {
- for my $i (0..$#{$-{dupe}}) {
- printf "dupe[$i] = %d\n", $-{dupe}[$i];
- }
- }