in reply to Doing by global regex does not work as on debug

That's a tautological mess.°

You've just invented a super complicated

$str =~ s/kkl/***/g;

Please try to explain what you expect in an SSCCE

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) actually it's legal code, a conditional regex which is only true after the group inside lookahead assertion matched, but can't ever be false because the former assertion skips those positions already 🤷🏻‍♂️