in reply to Scoping Problem? - 'Use of uninititiated value...'

If I understand correctly, the generation loop (while($cyc_count2 <= keycount)) keeps track of the last few words using @feed and uses them to find a new word. The new word should be found using only the last two words, so @feed should only contain two values at any time, not three:
@feed = @keysout[0,1]; ... while($cyc_count2 <= $keysout){ my $w1 = $feed[0]; my $w2 = $feed[1]; #no $nw needed! ...
After this, the intent seems to be to generate a list of possible next words in which each word appears as many times as it follows these two words in the original text. I think this is the main bug, and the loop should read like this:
for my $word ( keys %{ $hash{ $w1 }{ $w2 }{ words } } ){ push @wordsList, ($word) x $hash{ $w1 }{ $w2 }{ words }{ $word }; }
This way, for each word that ever followed these two (according to the hash), that word is added the same number of times it was seen in this context in the original text.
I don't think this will solve all of the problems with this code, but it's closer to what the code was meant to do.
~dewey

Replies are listed 'Best First'.
Re^2: Scoping Problem? - 'Use of uninititiated value...'
by chinamox (Scribe) on Nov 06, 2006 at 01:52 UTC

    Jackpot!

    Thank you for your response, this was extremely helpful!

    -mox