my %temp; my @captured = grep { ++$temp{$_} == 2 } split / /, ;