[ The OP silently updated his question. This post is now obsolete. ]
- tr/// does not do what you think it does. Replace tr with s.
- Add the missing /.
- You have unescaped / characters in your replace string. Either escape them, or change the delimiter.
- $word contains text, not a regexp. Its content needs to be escaped.
- You probably also want to add the g modifier, which indicates you want to replace all occurances (instead of just the first one).
Result:
foreach(loop through each $word in search phrase) {
$answer =~ s{\Q$word\E}{<b><u>$word</u></b>}g;
}
Read perlop for details.