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