[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] calculation in replacement string



I need to do a search and replace, replacing on a function of one of the
matched regexps...  Eg:

s/^([^:]*)/${$1+4}/;

to change "84:thingies" to "88:thingies".  Anybody got any ideas?
The above actually replaces the 84 with the contents of the variable
$88.  And, yes, I know I could do something like:
s/^([^:]*)//;
$_ = $`. $1+4 . $';

But doing that with a complicated regexp (especially with a /g modifier)
is quite clunky, and nontrivial.


Thanks,
Peter