my %tallies; my %errors = { userdep_error => \@subscriber_error, network_error => \@network_error, system_error => \@system_error, }; sub do_GSM { my $fields = shift; if ( $$fields[9] eq 'MSubmit' ) { $tallies{MO_count}++; if ( $$fields[7] eq 'MsgAccepted' ) { $tallies{MO_success]++; } } if ( $$fields[13] eq 'SMPP' ) { $tallies{AT}++; } for my $type ( keys %errors ) { if ( any { /^\Q$$fields[11]\E$/ } @{$errors{$type}} ) { $tallies{"MO_$type"}++; } } } sub do_SMPP { my $fields = shift; if ( $$fields[9] eq 'ESubmit' ) { $$tallies{AO_count}++; if ( $$fields[7] eq 'MsgAccepted' ) { $tallies{AO_success}++; } } if ( $$fields[11] =~ /SMSC/ ) { for my $type ( keys %errors ) { if ( any { /^\Q$$fields[11]\E$/ } @{$errors{$type}} ) { $tallies{"AO_$type"}++; } } } } my %subs = ( GSM => \&do_GSM, SMPP => \&do_SMPP ); foreach my $Intermediate_file (@Intermediate_files) { unless ( open (INTER, $Intermediate_file )) { warn "open failed for $Intermediate_file\n"; next; } while () { chomp; my @fields = split(/\|/); &{$subs{$fields[12]}}( \@fields ); } } print "Completed the Imtermediate section....\n"; ...