use strict; use warnings; my %words = map { s/[.?!]$//; lc $_, $_ } split/\s+/,; open(NOUNS,'<',"nouns.txt") or die "Can't open noun database: $!\n"; while(){ s/\s+//g; print "\n!MATCH! ~ $words{lc $_} is a noun\n" if exists $words{lc $_}; } close(NOUNS);