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";