in reply to Dividing a file into groups of two words and counting them
my %pairs; local $/; my $data = <DATA>; my @words = split /\W+/, lc($data_; $pairs{ $words[$_].' '.$words[$_+1] }++ for 0..$#words-1; print "$pairs{$_}\t$_\n" for sort { $pairs{$b}<=>$pairs{$a} } keys %pairs; __DATA__ To be or not to be, that is the question Ask not what your country can do for you but what you can do for your +country I think therefore I am I drink therefore I am I'm drunk therfore I was Alas twas not to be
|
|---|