in reply to Re: using hash to find frequency count
in thread using hash to find frequency count
use strict; my $maxcount; my $find; my $file; my %hash; my $count; while(<>){ my @list = shift =~ /([a-xA-Z'\-]+)/g; foreach my $word (@list) { $count =++$hash{lc $word}; if ($count > $maxcount) { $maxcount = $count; } } } my $numwords= keys %hash; print "distinct words: $numwords\n"; print "frequency of most common word: $maxcount\n"; print "common word: $find";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: using hash to find frequency count
by jjohhn (Scribe) on May 15, 2005 at 04:07 UTC | |
by jjohhn (Scribe) on May 15, 2005 at 04:23 UTC | |
by ikegami (Patriarch) on May 15, 2005 at 13:44 UTC |