$attempt1 = "get_stuff()"; $attempt2 = "get_stuff\(\)"; $attempt3 = qq(get_stuff()); $newstr = "apple"; $data = $attempt1; $data =~ s/$attempt1/$newstr/; print "\n$data"; $data = $attempt2; $data =~ s/$attempt2/$newstr/; print "\n$data"; $data = $attempt3; $data =~ s/$attempt3/$newstr/; print "\n$data";