my %stopwords = map { $_ => undef } @stopwords; $/=" "; while(<>){ chomp; push @lessWords, $_ unless exists $stopwords{$_}; } #### my %stopwords = map { $_ => undef } @stopwords; $/=" "; @lessWords = grep( exists $stopwords{$_}, map {chomp; $_} <> )