in reply to RE: RE: RE: Selective substitution: not in Perl?
in thread Selective substitution: not in Perl?
And yes, you can actually write it like that, just as you see. If you're doing anything odd in the right hand side in a s///e, I recommend expanding it out like that.{ my $count = 0; $string =~ s{($pattern)}{ my $source = $1; $count++; if ($count == $target) { $source = $replacement; # replace! } $source; # either original or replacement now }ge; };
-- Randal L. Schwartz, Perl hacker
|
|---|