in reply to precompiling regular expressions
Try doing $re2 = qr/$string2/; after assigning to $string2 but only then, and then do the substitution like $string1 =~ s/$re2//g;.
Update: also try just doing the $string1 = s/$string//g; substitution without explicitly adding any precompilation, for perl is usually smart enough to figure out what you want to do and will probably not recompile the regular expression if it doesn't change.
|
|---|