in reply to How to find and remove duplicate elements from an array?

The answers in the FAQ don't modify the array in-place. In case that's what you need, you can do the following:
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";
This can be wrapped in a sub like so:
sub remove_duplicates(\@) { my $ar = shift; my %seen; for ( my $i = 0; $i <= $#{$ar} ; ) { splice @$ar, --$i, 1 if $seen{$ar->[$i++]}++; } } my @a = qw( a a b c c c d e f e f e a f g h h h ); remove_duplicates( @a ); print "@a\n";