in reply to Interpolate $1 in: s{...}{$to}

'capture 1 is $1' is a template. You need something to process that template. If you want to keep the current template format, you could use /ee aka eval EXPR (which has safety issues) or String::Interpolate (which has an unconventional interface), or you could switch to something designed to be a template (e.g. Template::Toolkit).