http://qs321.pair.com?node_id=342430

While this type of problem has been solved many times over, I believe this to be the least processor intensive solution. It creates a hash (%unique) and gives it a key equal to each value in the array by making it equal to 1. Then it takes the keys of %unique and assigns those to an array as its value. Since duplicates will just reassign 1 to the existing key this always removes every duplicate without skipping anything within the array.

Update:Ignore my code, a far better way to do it was suggested below: @unique{ @a} = 1; @awd2 = keys %unique;

my %unique; foreach my $thingy (@array_with_duplicates) { $unique{$thingy} = 1; } my @array_without_duplicates = keys %unique;