in reply to Dividing a file into groups of two words and counting them
you could sayforeach $word(@word) { $count{$word}++; }
for $w (0 .. $#word) { $count{$word[$w].' '.$word[$w+1] }++; }
Beware of having an odd number of words in the file; you might pretest and stick a blank in the final (even) entry.
The code hasn't been tested, but I hope you get the idea.
|
|---|