in reply to Interpolate into replacement with s//?

It was a little hard to find, but this may be what you want:

perlretut Says:
A modifier available specifically to search and replace is the s///e evaluation modifier. s///e treats the replacement text as Perl code, rather than a double-quoted string. The value that the code returns is substituted for the matched substring. s///e is useful if you need to do a bit of computation in the process of replacing text. This example counts character frequencies in a line:
  • Comment on Re: Interpolate into replacement with s//?

Replies are listed 'Best First'.