wordcount.pl
Gracias, Andrew McNaughton! (via Sigia-l)
----- wordcount.pl ------- #!/usr/bin/perl use strict;#count words from stdin
my %count;
while (<>) {
my @words = m/([a-z][a-z']*[a-z]|[a-z])/ig;
foreach my $word (@words) {
$count{lc $word}++;
}
}# list frequencies to stdout
foreach my $word (sort {$count{$b} <=>
$count{$a}} keys %count) {
print "$word: $count{$word}\n";
}--------------------------
in Form: Script, Process: Scripting, Topic: IA
Previous Entry: RSS
Next Entry: You Will be Assimilated
Comments & TrackBacks
Comments and trackbacks are closed.