in reply to Re^3: Resetting variables
in thread Resetting variables

Oops! I pasted an older version of my code...at one point I had that sub coded like this, but went to this incorrect way (as I now understand) to try to fix bugs.
sub reset_game { ($good_guesses, $bad_guesses) = ""; $tot_found = 0; $found_one = 0; $occurrences = 0; $all_occurrences = 0; $guessed_word = 0; }

Replies are listed 'Best First'.
Re^5: Resetting variables
by davido (Cardinal) on Dec 21, 2004 at 18:10 UTC

    Oops indeed. I spent time on that for you.

    Once again I don't know what your current code looks like. The code you posted above does give the error message you described, for the reason I described. Your newly posted reset_game() sub will not generate the same error, but still contains a bug. Hint: Why are you putting [$all_occurrences] within a character class to check what the user entered, when you've assigned a value of '0' to $all_occurrences? What is that supposed to do?


    Dave

      If you look at my reply here I posted my entire script. $all_occurences is being populated in the check_guess() sub. It keeps a list of index values in the word the player is trying to guess so that when I am printing out the word, I print all of the guesed letters.