#Initialize the counter before the loop my $true_positives=0; while(){ ... #instead of the push $true_positives++;