use strict; use warnings; my @Uniq = uniq('a', 'b', 'c', 'a', 'b', 'a'); print "@Uniq\n"; sub uniq { return keys %{{map {$_=>1} @_}}; } OUTPUT: c a b