use strict; my @keyset = qw/this repeat that repeat/; my @valset = qw/jerry george elaine kramer/; print "\@keyset has ", hasdup(\@keyset) ? "duplicates (warning)" : "no duplicates", "\n"; print "\@valset has ", hasdup(\@valset) ? "duplicates" : "no duplicates", "\n"; sub hasdup { my $array = shift; # get the index of the elements in the uniq array my $last = $#{[keys %{{ map {$_ => 1} @$array }}]}; return $#{@$array} != $last; }