use strict; use warnings; use autodie; use List::MoreUtils qw( any ); my %drop_words; open my $words_ifh, '<', 'words.txt'; while( <$words_ifh> ) { $drop_words{ ( split /\s+/, $_, 2 )[0] } = 1; } close $words_ifh; open my $temp_ifh, '<', 'temp.txt'; open my $result_ofh, '>', 'temp_mod.txt'; while( <$temp_ifh> ) { chomp; next if any { exists $drop_words{$_} } split /\s+/; print {$result_ofh} $_, "\n"; } close $temp_ifh; close $result_ofh; #### next if defined first { exists $drop_words{$_} } split /\s+/;