@crops = qw(wheat corn barley rice corn soybean hay
alfalfa rice hay beets corn hay);
@dupes = grep { $count{$_} == 2 } #Exact two occurance
grep { ++$count{$_} > 1 } @crops; #more than two occurance
print "@dupes\n";
alfalfa rice hay beets corn hay);
@dupes = grep { $count{$_} == 2 } #Exact two occurance
grep { ++$count{$_} > 1 } @crops; #more than two occurance
print "@dupes\n";
No comments:
Post a Comment