Here's the whole thing again after I took another swing through it.
#!/usr/bin/perl -w
use strict;
use File::Slurp;
my ( %dictionary, %not_in_dictionary );
sub getfile { local *ARGV ; @ARGV = shift ; wantarray ? map /(.*)/, <>
: do { local $/ ; <> } }
%dictionary = map { ( $_, 0 ) } grep { ! /^\s*$/ } getfile(
'/usr/share/dict/words' );
my $text = getfile( './kjv10.txt' );
( 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.
*/