@array1 = @array1[slicer(@array1)]; @array2 = @array2[slicer(@array1)]; sub slicer { grep { $_[$_] =~ /keep these/ } 0 .. $#_; }