my %seen; for ( my $i = 0; $i < scalar @arr; $i++){ splice @arr, $i--, 1 if $seen{$arr[ $i]}++; }