I'd be inclined to maximize the use of distinct subroutines for specific subsets of data, as well as using more hashes to organize things according to types and labels. Here's how I would try to structure the first part of the OP code. (I think the array idea mentioned above will help a lot with the rest.)

I have no way of testing this proposal in a relevant way, but I think the layout is basically in line with what you're trying to do. (Note that I'm renaming your "$AO_ESMEdep_error" to a hash key spelled "AO_userdep_error", to maintain parallelism between the GSM and SMPP conditions - I hope that doesn't warp things too much for you (the parallelism is worth it, I think).

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 (<INTER>) { chomp; my @fields = split(/\|/); &{$subs{$fields[12]}}( \@fields ); } } print "Completed the Imtermediate section....\n"; ...
I also altered the handling of open failures and shortened the variable names.

In reply to Re: Making program readable by graff
in thread Making program readable by ravi45722

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.