I'm trying to make a hangman game and I've run into a specific issue with the tr/// function. I want to replace the letters in the phrase that have not been guessed yet. This code does not work and I know that the highlighted line is the wrong one but I can't figure out how to make it work. Any help will be very appreciated. This is not homework. I am trying to create problems for my student that I tutor. I know there are probably different ways of solving this problem, but I would like to stick with the tr/// operator because it makes the most sense to me.
Perl:
$Phrase = "I'm trying to find this phrase.";
$guess = "abcde";
print "I already guessed these letters: $guess\n";
$sub=$Phrase;
$alphabet='abcdefghijklmnopqrstuvwxyz';
$alphabet =~ s/$guess//g;
print "These letters should still be hidden: $alphabet\n";
[highlight #FCE94F]$sub =~ tr/$alphabet/\-/;[/highlight]
print "$sub\n";