in reply to Having scalars handled as regexs inside a substitution

$find is taken care of automatically, but you need to evaluate $replace, twice: $string =~ s/$find/$replace/gee; The first time gives you $1, and the second evaluates that to become the first parenthetical match. Example:
#!/usr/bin/perl -w use strict; my $string = "abcabcabc"; my $find = "a(bc)"; my $replace = '$1'; $string =~ s/$find/$replace/eeg; print ">>$string<<\n";
Note that $replace is defined via single quotes. That's to avoid interpolation in the assignment -- otherwise, there's an undefined value error.