if ( $line =~ /$current_date/ ) { foreach my $error (@errors) { # count all the errors on the line ++$error_count while ($line =~ /($error)/g); } }