if(my $b = $all_current_home_plays->search({ b_pass => 1 })) { my $count = $b->count; if($count >0) { #CALCULATIONS NEEDING A PASS PLAY TO HAVE OCCURRED my $completes = $count - $b->search({ b_incomplete => 1 })->count; my $sum = $b->get_column('yards')->sum; my $ints = $b->search({ b_intercepted => 1 })->count; if(my $c = $b->search({ down => 1 })) { my $acount = $c->count; if($acount > 0) { $stats{HTO_1st_YPP} = $b->search({ down => 1 })->get_column('yards')->sum / $acount; my $totals; while(my $d = $c->next) { $totals += $d->_get_pass_score; } $stats{HTO_1st_Pass_Score_Avg} = $totals / $acount; } }