my $matches = 2; my $threshold = 8; my @results = (); foreach my $row (@arr) { my $count; for (1..$#$row) { $count++ if($row->[$_] >= $threshold); } push @results, $row if($count >= $matches); } foreach(@results) { say join ",", @$_; } #### my $matches = 2; my $threshold = 8; my @results = grep { $matches <= scalar grep { $_ >= $threshold } @$_[1..$#$_]; } @arr; foreach(@results) { say join ",", @$_; } #### D,6,7,8,8 F,4,8,8,8