foreach(@sorted) { my $frmType = substr $_, 1, 4; if ($frmType eq "Q569") { print OUT "$_"; $count ++; } } print OUT "There were $count Quarterly 569 runs\n";