in reply to Re: incremental substitution w/ regexp only?
in thread incremental substitution w/ regexp only?
Something like this works better:>perl -wMstrict -le "my $test = 'abc1 abc1 abc1 abc1 abc1'; $test =~ s/1/++$1/eg; print $test; " Modification of a read-only value attempted at -e line 1.
>perl -wMstrict -le "my $addend = 0; my $test = 'abc1 abc1 abc1 abc1 abc1'; $test =~ s/(1)/$addend++ + $1/eg; print $test; " abc1 abc2 abc3 abc4 abc5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: incremental substitution w/ regexp only?
by ikegami (Patriarch) on Dec 25, 2008 at 14:32 UTC | |
by AnomalousMonk (Archbishop) on Dec 25, 2008 at 16:19 UTC |