http://www.perlmonks.org?node_id=917134


in reply to need help in extending the code

#!/usr/bin/perl -w use strict; my $x= "it is not probably that it is the end"; my @ngram; my @wds = split(' ',$x); while (@wds>=3) { push @ngram, join(" ",@wds[0..2]); shift @wds; } print join("\n",@ngram),"\n"; __END__ it is not is not probably not probably that probably that it that it is it is the is the end