$#letters is the index of the last element in @letters (or -1 if there are no elements). $blankword[$i] accesses the element at index $i of @blankword. The loop foreach $i (0..$#letters) {...} prints each of the known letters in the word and prints a '-' for any unknown letters. The if ($blankword[$i]) tests to see if a letter is known or unknown by testing to see if the element is zero or not.
In scalar context @array returns the number of elements in @array (cf $#array above). So $guesses[@guesses]=$guess; assigns $guess to the next unused element in @guesses. It would be more Perlish to push @guesses, $guess instead.
In reply to Re: hangman question
by GrandFather
in thread hangman question
by convenientstore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |