in reply to evaluating $1 in a replace string

You might want to take a look at the 'e' modifier for s///. It is an option to have the right side evaluated as an expression.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.