$string = 'string with word foo in it'; $find = '(foo)'; $replace = '\1bar'; $string =~ s/$find/$replace/g;