Возможно, вам будет полезно узнать об этом подробнее.
# Hash to keep track of what you've seen
my %seen;
# Array to store the first occurrence of each value
@values;
foreach my $x (@_) {
# If we haven't seen this value already
if (!$seen{$x}) {
# Push this value onto @values
push @values, $x;
}
# Increment the value in %seen to say we've seen this value
$seen{$x}++;
}
# At the end, the unique values are in @values