No, that's correct. What was the the second code (shown below) returned pairs of words as an array. You might want to take a peek at Data::Dumper to easily display structures. In any case, I've since modified my post such that the code does what you want.
my @words; while ($content =~ /($word)/g) { push(@words, $1); } my @words_bi; my @words_tri; foreach (0..$#words) { next if $_ < 1; push(@words_bi, [ @words[$_-1 .. $_] ] ); next if $_ < 2; push(@words_tri, [ @words[$_-2 .. $_] ] ); }
In reply to Re^3: Word density
by ikegami
in thread Word density
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |