my @a = qw( a a b c c c d e f e f e a f g h h h ); my %seen; for ( my $i = 0; $i <= $#a ; ) { splice @a, --$i, 1 if $seen{$a[$i++]}++; } print "@a\n";