... what is the point of failure ...
There is no failure. As LanX pointed out, the regex is doing exactly what it's been told to do.
Win8 Strawberry 5.30.3.1 (64) Sat 12/04/2021 21:26:27 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings my $str='kklmn'; # +--------------- if you look ahead to kkl # | # | +---+-------- while also capturing it to capture group 1 # | | | (match point is not advanced) # | | | # | | | +-------- and then if capture 1 captured anything # | | | | # | | | | +----- match with what was captured to $1 # | | | | | # | | | | | +-- else match with mn # | | | | | | # | | | | | | +------- and substitute this # | | | | | | | # v v---v v v v v $str=~ s/(?=(kkl))(?(1)\g1|mn)/***/g; print "'$str' \n"; ^Z '***mn'
Update (many days later):
... what is the point of failure ...The point of failure is to learn.
Give a man a fish: <%-{-{-{-<
In reply to Re: Doing by global regex does not work as on debug
by AnomalousMonk
in thread Doing by global regex does not work as on debug
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |