$dictfile="/some/path/to/dictfile"; #Dictfile should have a all words (or regex for words), one per line open (DICT, $dictfile) or die "Can't open $dictfile:$!"; while(){ $words{lc($_)}=1; #using hash as cheap lookup #Note that a "real" dictionary file will nail you on efficency here. Perhaps a Dbm would be better? } while(<>){ foreach $word (split($_)){ if (!defined($words{lc($word)})){ print "$.:$word?\n"; } } }