http://www.perlmonks.org?node_id=280788


in reply to Perl Idioms Explained - keys %{{map{$_=>1}@list}}

Just as memory hungry, still not order preserving, and still broken with regards to undefined values, but faster approach:
my %seen; @seen{@list}=(); my @uniq = keys %seen;
And if you want to wrap it up without "leaking" lexicals:
my @uniq = do { my %seen; @seen{@list}=(); keys %seen; };
This approach does not (explicitly) iterate - more of the data structure setup work is done implicitly by perl.

Makeshifts last the longest.