my @crops = qw(wheat corn barley rice corn soybean hay alfalfa rice hay beets corn hay); my @dupes = grep { $count{$_} == 2 } grep { ++$count{$_} > 1 } @crops;print "@dupes\n";