http://qs321.pair.com?node_id=1143893


in reply to Making program readable

I have no OO techniques to suggest, just write clearer code.

Don't repeat yourself so much. This :-

if ($intermediate_array[12] eq "GSM" && $intermediate_array[9] + eq "MSubmit") { $intermediate_MO_cnt++; } if ($intermediate_array[12] eq "GSM" && $intermediate_array[9] + eq "MSubmit" && $intermediate_array[7] eq "MsgAccepted") { $total_MO_success++; }

could be written as :-

if ($intermediate_array[12] eq "GSM" && $intermediate_array[9] eq +"MSubmit") { $intermediate_MO_cnt++; if ( $intermediate_array[7] eq "MsgAccepted") { $total_MO_success++; } }

It's clearer and easier to see what your intent was, and there are fewer places for bugs to hide.

Variable names like $del_user1_error , $del_user2_error, .. $del_userN_error are always a sign that you should have used any array and you're writing too much code. So instead you could do something like this :-

my @del_user_error_count; for my $i (0..4) { if ($cdr_post_array[11] eq $del_user_errors[$i]) { $del_user_error_count[$i]++; last; } }