in reply to hangman question

2)can someone please explain to me in plain english what
$guesses[@guesses]=$guess;
@guesses is in scalar context there, so it produces the number of elements in the array. That is used as an index to assign to an element of the array. Since the pre-assignment elements are numbered 0 through (@guesses - 1), it adds a new element to the end of the array.

A much clearer way to write it would be:

push @guesses, $guess;

Replies are listed 'Best First'.
Re^2: hangman question
by Anno (Deacon) on Jul 16, 2007 at 11:13 UTC
    There is at least one case where the construct
    $guesses[@guesses]=$guess;
    makes sense, which is when you want the new element to autovivify. You can say
    $guesses[@guesses]->{ key} = 'value';
    to create a hashref in the new place. With push() you'll have to create the hash yourself.

    Anno