in reply to Re^2: hangman question
in thread hangman question
No. $i gets assigned 0, 1 and 2 - indexes into the two arrays, not the contents of the elements of @letters. 0 .. $#letters is the list context range operator and generates a list containing the integers from 0 to the index of the last element in @letters (0, 1 and 2 for this example).
The code depends on elements of @blankwords being set to 0 until they are assigned a correct letter. The test could be rewritten if ($blankword[$n] eq $letters[$i]) { to make an explicit check that the correct letter has been guessed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: hangman question
by convenientstore (Pilgrim) on Jul 16, 2007 at 02:00 UTC | |
by ysth (Canon) on Jul 16, 2007 at 02:46 UTC | |
by convenientstore (Pilgrim) on Jul 16, 2007 at 03:48 UTC |