my $new = ''; for (;;) { # or: for ($orig) if (/\G(.*?)(this)/sgc) { say "Matched $2 at $-[2]"; $new .= $1 . 'that'; redo; } else { /\G(.*)/sgc; $new .= substr($_, pos); last; } }
In reply to Re: Loop through global substitution
by ikegami
in thread Loop through global substitution
by alafarm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |