in reply to Counting words

Anonymous Monk,
I think what you are asking is:

How do I get a list of words, defined by white space, in a file and the number of times they appear. I realize that words like "book keeper" which can be spelled with or without a space, different case, and words that wrap lines are going to be an issue, but I want a 99% solution.

#!/usr/bin/perl use strict; use warnings; my $file = $ARGV[0] || 'foo.txt'; open (INPUT, '<', $file) or die "Unable to open $file for reading : $! +"; my %word; while ( <INPUT> ) { chomp; $word{$_}++ for split " "; } print "$_ : $word{$_}\n" for sort { $word{$b} <=> $word{$a} } keys %wo +rd;
It isn't perfect (99% solution), and the sort routine is not the most efficient, but you get the idea.

Cheers - L~R