my %seen; my @ABC; for my $element (@XYZ) { next if $seen{$element}++; push @ABC, $element; } @XYZ = @ABC;