my @ary = qw(a b c d d e b d); my %hsh; undef @hsh{@ary}; my @ary2 = keys %hsh; print "@ary2\n";