This subroutine sets $guess to the letter from the terminal and erases the letter from @alphabet.
Get a guess from the keyboard like sec.5.1, Terminal Input.
sub erase_guess { while(<>){ chomp; # Trim the newline from $_ $guess = lc($_); # convert to lower case # $i is an iteration variable for @alphabet # $alphabet[4] is 'e', $alphabet[13] is 'n', etc. $i = 0; foreach $l (@alphabet){ # Replace the letter with a space. if ($l eq $guess){ $alphabet[$i] = " "; } $i++; } last; # One letter at a time } }