# method 1 { my %uniq; @uniq{@elements} = (); # placing them into piles @uniq = keys %uniq; # getting one from each pile } # method 2 { my %seen; @uniq = (); for (@elements) { push @uniq if !$seen{$_}++; # inserting if not seen } }