ignoranceisblis
03-04-2005, 08:35 PM
I'm trying to write a hangman game but I'm not sure how to count the letters of a variable
I need a way to say
my $hangman = "medical"; # random word to play with
if ($response =~ /@letters/) { # $response is the user's ressponse and $letters is all the letters of $hangman
@knownletters = @knowletters + $response; # somehow :)
}
somhow replace all the letters of hangman that we don't know about with under scores
print $hangman;
I could think of a couuple long drawn out ways of accomplishing this but I wanted to see if anyone had any ideas first.
Is there an easy way to do this?
I need a way to say
my $hangman = "medical"; # random word to play with
if ($response =~ /@letters/) { # $response is the user's ressponse and $letters is all the letters of $hangman
@knownletters = @knowletters + $response; # somehow :)
}
somhow replace all the letters of hangman that we don't know about with under scores
print $hangman;
I could think of a couuple long drawn out ways of accomplishing this but I wanted to see if anyone had any ideas first.
Is there an easy way to do this?