$problem= "["; $str= "(input)"; $str =~ s/input/input value="$problem"/; print "<$str>\n"; # produces <(input value="[")>