in reply to removing repeated elements from one array
Have you used the "Search" box or Super Search to find an answer? Searching for "Removing duplicates", I find Removing Duplicates from an Array and Removing Duplicates in an array?. Searching with Google, the first hit already is an answer. perldoc -q duplicate has the FAQ on that question.
In short, you want to keep track of all items you've already seen, for which a hash is a convenient datastructure:
my %seen; for my $item (@array) { $seen{$item}++ # remember this item }; my @unique = keys %seen; # The order gets lost though
|
|---|