Hidden Bug:

if ($line =~ /Entering UPAuthModule::authenticate/ .. /Sending Invalid + credential/ )
omits the `$line =~` from the second half of the flip-flip operands. It should read:
if ( ( $line =~ /Entering UPAuthModule::authenticate/ ) .. ( $line =~ +/Sending Invalid credential/ ) )

Subtle Bug: It is usually wrong to use printf() with variables imbedded in the template. From `perldoc -f printf`:

Don't fall into the trap of using a "printf" when a simple "print" would do. The "print" is more efficient and less error prone.
Either use print "Total is $total\n"; or printf "Total is %d\n", $total;.

Other than that, I think davorg++ has pointed out the major problem; you are only actually processing the last log file. Here is an example of refactored flow:

#!/usr/bin/perl use strict; use warnings; my $usage = "usage: $0 <logDir> <logPrefix>"; die "$usage\n" if @ARGV != 2; my ( $dir, $prefix ) = @ARGV; die "Log dir '$dir' doesn't exist" unless -d $dir; my $glob_path = "$dir/${prefix}*"; my @log_paths = glob $glob_path or die "No files found in '$glob_path'"; Total_Number_Of_Transactions( @log_paths ); sub Total_Number_Of_Transactions { die if not @_; my @log_files = @_; my $Success_QnA_Count, $Success_ArcotID_Count, $Success_OTP_Count, + $Success_UP_Count ) = ( 0, 0, 0, 0 ); my $Failure_QnA_Count, $Failure_ArcotID_Count, $Failure_OTP_Count, + $Failure_UP_Count ) = ( 0, 0, 0, 0 ); my $total_filename = 'total_transactions'; for my $log_file (@log_files) { open my $log, '<', $log_file or die "Can't open '$log_file' for reading."; while( <$log> ) { s{\s+\z}{}; do { $Success_ArcotID_Count++; next } if /ArcotID\s*Auth\s +*SUCCESS/; do { $Failure_ArcotID_Count++; next } if /Auth failed/; do { $Success_QnA_Count++ ; next } if /QNA Auth - Succe +ss/; do { $Failure_QnA_Count++ ; next } if /Message: QNA Aut +h Failed/; do { $Success_OTP_Count++ ; next } if /OTP SUCCESS/; do { $Failure_OTP_Count++ ; next } if /Message: OTP FAI +LED/; do { $Success_UP_Count++ ; next } if /UPAuth SUCCESS/; do { $Failure_UP_Count++ ; next } if /UPAuth FAILED/; } close $log or warn; } open my $total_fh, '>', $total_filename or die "Cannot create file '$total_filename' for writing"; printf $total_fh "%7d Total count for ApricotID\n" , $Success +_ArcotID_Count + $Failure_ArcotID_Count; printf $total_fh "%7d Total count for QnA\n" , $Success +_QnA_Count + $Failure_QnA_Count; printf $total_fh "%7d Total count for OTP\n" , $Success +_OTP_Count + $Failure_OTP_Count; printf $total_fh "%7d Total count for User Password \n", $Success +_UP_Count + $Failure_UP_Count; close $total_fh or warn; }


In reply to Re: problem in output by Util
in thread 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.