$string = 'string with word foo in it'; $find = '(foo)'; $replace = '"${1}bar"'; $string =~ s/$find/$replace/eeg;