in reply to finding unique elements in an array

Use a hash to count the number of unique elements in the array:
my %array_count; foreach my $elem (@array) { $array_count{$elem}++; } foreach my $key (keys %array_count) { print "$key\n" if $array_count{$key} == 1; }
It probably can be done shorter, but I think this code conveys the idea quite clearly.

The elements of the array become the keys of the hash, and the values of the hash are the number of times that the element is present in the array.

Arjen