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

my @A = (1,2,2,3,4,5); my %hash = (); grep {$hash{$_}++}@A; my @result = keys %hash; print @result;

Originally posted as a Categorized Answer.