- or download this
while ($string =~ /abc/ig) {
my $ins = sprintf(" def(%s)", $x++);
...
$string =~ s/\G/$ins/;
pos($string) = $pos + length($ins);
}
- or download this
while ($string =~ /abc/ig) {
my $ins = sprintf(" def(%s)", $x++);
...
substr($string, $pos, 0, $ins);
pos($string) = $pos + length($ins);
}
- or download this
$string =~ s/(abc)/ sprintf("%s def(%s)", $1, $x++) /eig;