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

or use sprintf. Search for "format parameter index" if you need to rearrange or repeat the ordering of the matches in the output.

sub foo { my ($from, $to) = @_; return sprintf($to, ($from =~ /.../)); }

--MidLifeXis