It's hard to tell which result you expect, but the way pos is changed after replacing a zero length assertion is tricky. It's meant to avoid endless loops.
use v5.12; use warnings; use Data::Dump 'dd'; $_ = 'aa'; s/(?=(a))(?{say "\$1='$1' \@-=(@-) pos=",pos})/b/g; dd [$1]; dd \@-; dd $_; __END__ $1='a' @-=(0 0) pos=0 $1='a' @-=(0 0) pos=0 $1='a' @-=(1 1) pos=1 $1='a' @-=(1 1) pos=1 ["a"] [1] "baba"
this may shed some light
use v5.12; use warnings; use Data::Dump 'dd'; $_ = 'ab'; s/(?=([ab]))(?{say "\$1='$1' \@-=(@-) pos=",pos})/X/g; dd [$1]; dd \@-; dd $_; __END__ $1='a' @-=(0 0) pos=0 $1='a' @-=(0 0) pos=0 $1='b' @-=(1 1) pos=1 $1='b' @-=(1 1) pos=1 ["b"] [1, 1] "XaXb"
Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery
In reply to Re: Global match and capture group in look-ahead == under-populated "@-"? (updated)
by LanX
in thread Global match and capture group in look-ahead == under-populated "@-"?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |