in reply to Create n-grams from tokenized text file

This assumes you can get the words into an array:

@x = qw[ this is the text to play with ];; $n = 2; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is is the the text text to to play play with $n = 3; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is the is the text the text to text to play to play with $n = 4; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is the text is the text to the text to play text to play with $n = 5; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is the text to is the text to play the text to play with

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.