For small arrays, lots of approaches work. For large ones, how about
* Putting the elements of @arrayindex in a hash for fast access.
* Go thru @array, incrementing a counter. If the counter value is in indexHash, select the element. Otherwise, pass an empty list
my %indexHash;
my $ix =0;
foreach (@arrayindex){
$indexHash{$_}=1};
my @cleansedArray =
map { $indexHash($ix++) ? $_ : ()} @array
throop