if ($line =~ /Entering UPAuthModule::authenticate/ .. /Sending Invalid credential/ ) #### if ( ( $line =~ /Entering UPAuthModule::authenticate/ ) .. ( $line =~ /Sending Invalid credential/ ) ) #### #!/usr/bin/perl use strict; use warnings; my $usage = "usage: $0 "; 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 - Success/; do { $Failure_QnA_Count++ ; next } if /Message: QNA Auth Failed/; do { $Success_OTP_Count++ ; next } if /OTP SUCCESS/; do { $Failure_OTP_Count++ ; next } if /Message: OTP FAILED/; 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; }