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