foreach my $word (@words) { chomp($word); foreach my $posWord (@positiveWords) { chomp($posWord); if ( lc($word) eq $posWord) { $numPosWords++; last; } } foreach my $negWord (@negativeWords) { chomp($negWord); if ( lc($word) eq $negWord) { $numNegWords++; last; } } }