in reply to not getting desired output
Problems:
/[4]/ matches "4", not "[4]".
You never exit the inner loop before the end of the file.
$errorCode != 0 || $errorCode != 1
should be
$errorCode != 0 && $errorCode != 1
The former is always true.
die ... unless -f "$logFile"; is useless, even harmful. open not only performs this check, but can provide a better error message.
You call <> (in the outer loop) after being told you've reached the end of the file (in the inner loop).
\[ is more usual and readable than [[]
\] is more usual and readable than []]
while (...) { ...; next }
is the same as just
while (...) { ...; }
Fix:
use strict; use warnings; my $ArcotIDError_Count = 0; OUTER: while(my $line = <>) { $line =~ tr/\r\n//d; next if $line !~ /Handling NSPAdvice for mechanism \[4\]/; do { $line = <>; last OUTER if !defined($line); } while $line !~ /Authentication mechanism returned \[(\d+)\]/; my $errorCode = $1; #print("\$errorCode=$errorCode\n"); if ($errorCode != 0 && $errorCode != 1) { $ArcotIDError_Count++; } } print "Total Number Of ArcotID Authentication ErrorCode returned is $A +rcotIDError_Count\n";
( I see that others have identified some of the issues, but not all. )
Update: Reordered points by descending severity.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: not getting desired output
by namishtiwari (Acolyte) on Jun 11, 2009 at 16:06 UTC | |
by ikegami (Patriarch) on Jun 11, 2009 at 17:14 UTC | |
by ikegami (Patriarch) on Jun 11, 2009 at 17:13 UTC | |
|
Re^2: not getting desired output
by namishtiwari (Acolyte) on Jun 11, 2009 at 16:04 UTC |