use List::MoreUtils qw(uniq); my @a=qw(1 3 4 1 2 3); print join("-",uniq(@a))."\n";