my @array = qw( foo bar bar baz ); my %h; $h{$_}++ for @array; my @dup = grep $h{$_} > 1, keys %h; print join( ", ", @dup );