This is a variation on perlfaq5 – How can I remove duplicate elements from a list or array?
Just use a hash to count the elements, and then print the ones seen only once.
use strict;
use warnings;
my @array = qw(18 1 18 3 18 1 1 2 3 3);
my @nondup = do {
my %count;
$count{$_}++ for @array;
grep {$count{$_} == 1} keys %count;
};
print "@nondup\n";
Outputs:
2
2
solved Perl find the elements that appears once in an array