All those while ( $line = <$log> ) seems to me a bad design of your algorithm. If any of the ifs inside them fails, you will consume all the input in a inner while. It seems that at some point one of your regular expressions inside and if statement is failing, thus consuming the rest of the fail. I would also recommend you to use strict and use warnings in your code, specially in code you are testing and (like this case) is giving problems.
I want to count it in between these lines...
The range operator (see perlop) could be an alternative for this. Something like (untested):
while (my $line = <$log>){
if (/recvd AA_BIN_MSG_VER_CHG/ .. /?:(Prepared to Send OK|Sending I
+nvalid credential)/){
if (/Handling NSPAdvice for mechanism \[4\]/ .. /whatever_condit
+ion_to_reset_this_block/) {
if ($line =~ /Authentication mechanism returne
+d \[(\d+)\]/) {
my $errorCode = $1;
print "$errorCode\n";
$ArcotIDError_Count++ if ($errorCode != 0 && $errorCode !
+= 1);
}
}
}
}