in reply to macthing a word a in array of words

Where|How do you populate @wrds ("words" is not too long to type, mind you) before entering the while loop?

In if($word = @wrds[$w]), as $w is never being incremented & remains undefifned, $word is assigned undef every time. Use eq operator to test equality of strings (== to test equality of numbers).

To match a user given word in a pre-populated array, iterate over the array of words inside the trial loop.

Replies are listed 'Best First'.
Re^2: matching a word a in array of words
by Anonymous Monk on Apr 02, 2011 at 14:59 UTC
    In if($word = @wrds$w), as $w is never being incremented & remains undefined, $word is assigned undef every time.

    Ah, never mind that as I missed $w++ earlier. (Found other problems in code but too tedious to point them out.)

    OP, what is your pseudocode?