in reply to Create n-grams from tokenized text file

I don't really understand your code ...

here a variation which avoids reading the whole file in once, but instead line by line

use strict; use warnings; my @cache; my $n=4; while (my $line =<DATA>) { chomp $line; push @cache, $line; if (@cache >= $n) { print "@cache\n"; shift @cache; } } __DATA__ One Two Three Four Five Six Seven Eight Nine Ten

(Marshall++ was faster)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!