while () { my @words = split /\s+/,lc $_; ++$uniq1{$_} for @words; } #### #!perl my %uniq1= ( cow => 1, dog => 1, fox => 1, ); my @words = ('ant','bat','cat','dog','eel','fox'); my @match = grep $uniq1{$_}, @words; print "@match\n"