in reply to RegEx - Using Templates
The easiest thing is to use the /e modifier: $text =~ s/$v1/$v2/e;Read more about it in perlre.
Update This is wrong; follow Zaxo's advice below.