foreach my $i (sort { $b <=> $a } unique(@arrayindex)) { splice @array, $i, 1; }