in reply to Compiling Search/Replace Regexs

The right hand side is not a regex so you shouldn't try to compile it. In the example above you could just do
s/$lhsCompiled{$lhs}/XXX$1/
If you want to vary the right hand side depending on $lhs then you could do
s/$lhsCompiled{$lhs}/&{$rhsSubs{$lhs}}($1)/
so that each left hand side can have a corresponding right hand side.