in reply to
Markov Chain Program
To improve of this, you may have to rethink your data structures. I've had good results by weighting the random choice of the next token based on its frequency of occurence after the prior n tokens (where n==2 in your code).
One approach would be to extend your data structure along the lines of
%wordslist = (
'blessed is' => ['the', 47, 'a', 23, 'vroom', 1],
and then to use the frequency counts to weight the random choice.
For an object-oriented approach that builds n-deep trees, take a look at