Hi Monks, Here is my piece of code,
#!/usr/bin/perl Total_Number_Of_Transactions() ; sub Total_Number_Of_Transactions { my $logfile = $Logfile; my $logDir = $ARGV[0]; my $logPrefix = $ARGV[1]; die "usage: $0 <logDir> <logPrefix>" unless $logDir and $logPrefix; die "Log dir $logDir doesn't exist" unless -d "$logDir"; for my $logFile ( glob("$logDir/${logPrefix}*") ) { open($log, "<", $logFile) or die "Can't open $logFile for reading."; open(FP_OUT,">total_transactions") or die "cannot create file total_tr +ansactions for writing"; } my $Total_QnA_Count = 0; my $Total_OTP_Count = 0; my $Total_UP_Count = 0; my $Total_ArcotID_Count = 0; my $Success_QnA_Count =0; my $Failure_QnA_Count = 0; my $Success_ArcotID_Count = 0; my $Failure_ArcotID_Count = 0; my $Success_OTP_Count = 0; my $Failure_OTP_Count = 0; my $Success_UP_Count = 0; my $Failure_UP_Count = 0; OUTER: while( $line = <$log> ) { $line =~ tr/\r\n//d; if ($line =~ /Arcot Native Server: recvd AA_BIN_MSG_VER_CHG/) { while ($line = <$log>) { if ($line =~ /ArcotID\s*Auth\s*SUCCESS.*/) { $Success_ArcotID_Count++; next OUTER; } elsif ($line =~ /Auth failed.*/) { $Failure_ArcotID_Count++; next OUTER; } } } if ($line =~ /QNA Step - AUTH IN PROGRESS/) { while ($line = <$log>) { if ($line =~ /QNA Auth - Success.*/) { $Success_QnA_Count++; next OUTER; } elsif ($line =~ /Message: QNA Auth Failed.*/) { $Failure_QnA_Count++; next OUTER; } } } if ($line =~ /Entering OTPAuthModule::authenticate/) { while ($line = <$log>) { if ($line =~ /OTP SUCCESS.*/) { $Success_OTP_Count++; next OUTER; } elsif ($line =~ /Message: OTP FAILED.*/) { $Failure_OTP_Count++; next OUTER; } } } if ($line =~ /Entering UPAuthModule::authenticate/ .. /Sending Inv +alid credential/) { while ($line = <$log>) { if ($line =~ /UPAuth SUCCESS.*/) { $Success_UP_Count++; next OUTER; } elsif ($line =~ /UPAuth FAILED.*/) { $Failure_UP_Count++; next OUTER; } } } } $Total_ArcotID_Count = $Success_ArcotID_Count + $Failure_ArcotID_Count + ; $Total_QnA_Count = $Success_QnA_Count + $Failure_QnA_Count ; $Total_OTP_Count = $Success_OTP_Count + $Failure_OTP_Count ; $Total_UP_Count = $Success_UP_Count + $Failure_UP_Count ; printf FP_OUT "Total ApricotID count is $Total_ArcotID_Count\n"; printf FP_OUT "Total QnA count is $Total_QnA_Count\n"; printf FP_OUT "Total OTP count is $Total_OTP_Count\n"; printf FP_OUT "Total User Password count is $Total_UP_Count\n"; close(FP_OUT); close($log); }
It is not printing the correct output. the correct output is -- Total ArcotID count is -1187 Total QnA count is 74 Total OTP count is 4 Total User Password count is 2 but it is giving me- Total ArcotID count is 41 Total QnA count is 2 Total OTP count is 0 Total User Password count is 2 kindly give me some suggestions. I dont find any logic problem here. Thanks NT

In reply to problem in output by namishtiwari

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.