my $data = pdl ...; # 1-d #my $set1 = $data->where(something); # before Update 1 #my $set1 = $data->which(something); # before Update 2 my $set1 = which($mask1); # $mask1 having the shape of $data my $full1 = zeroes(indx, $data->dim(0))->setvaltobad(0); $full1->dice($set1) .= $set1; #my $set2 = $data->where(other); # before Update 1 #my $set2 = $data->which(other); # before Update 2 my $set2 = which($mask2); # $mask2 having the shape of $data # Now the intersection of $set1 and $set2 is: my $tmp = $full1->dice($set2)->sever; my $intersect = $tmp->where(isgood $tmp);