my $file = "C:\\areopagitica.txt"; open(IN, $file) || die "File not found"; my @thisfile = ; close(IN); chomp @thisfile; my %seen=(); while (@thisfile) { while ( /(\w['\w-]*)/g ) { $seen{lc $1}++; } } foreach my $word (sort { $seen{b} <=> $seen{a} } keys %seen) { printf "%5d %s\n", $seen{$word}, $word; }