Here's my perl contribution:
#!/usr/bin/perl -w
use strict;
use File::Slurp;
my ( %dictionary, %not_in_dictionary );
{ my @dictionary = do {
open my $D, "</usr/share/dict/words"
or die "Couldn't open words file: $!\n";
<$D>;
};
shift @dictionary;
chomp @dictionary;
@dictionary{ @dictionary } = ( 0 ) x @dictionary;
};
my $text = do {
open my $T, '<./kjv10.txt'
or die "Couldn't open kjv10.txt: $!\n";
local $/;
<$T>;
};
( exists $dictionary{ $1 }
? $dictionary{ $1 }++
: $not_in_dictionary{ $1 }++
) while $text =~ m/([\w'-]+)/g ;
print "\n\nThese words appeared N times and were in the dictionary:\n\n";
print "Dictionary word -> times appeared\n";
print "---------------------------------\n\n";
print join "\n", map { "$_ -> $dictionary{ $_ }" } sort keys %dictionary;
print "\n\nThese words appeared and were not in the dictionary:\n\n";
print "Non-Dictionary word -> times appeared\n";
print "-------------------------------------\n\n";
print join "\n", map { "$_ -> $not_in_dictionary{ $_ }" } sort keys
%not_in_dictionary;
--
Alan
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/