my @array = qw(a b c d a a a a e); my %hash; @hash{@array} = 1 x @array; print join(':', keys %hash);