in reply to Re^2: Word density
in thread Word density
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 .. $_] ] ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Word density
by Anonymous Monk on Mar 19, 2006 at 19:29 UTC | |
by sulfericacid (Deacon) on Mar 19, 2006 at 19:36 UTC | |
by ikegami (Patriarch) on Mar 21, 2006 at 01:26 UTC |