use List::MoreUtils qw(uniq); my @a=qw(1 3 4 1 2 3); print join("-",uniq(@a))."\n"; #### 1-3-4-2 #### my %h; @a=map { $h{$_}++ == 0 ? $_ : () } @a;