my %indexHash; my $ix =0; foreach (@arrayindex){ $indexHash{$_}=1}; my @cleansedArray = map { $indexHash($ix++) ? $_ : ()} @array