I thought we can do a better code (by not using all if's to check the conditions) using modules
No modules needed. Just use logic and nest/chain the if's:
for my $Postpaid_file (@Postpaid_files) { open my $POST, $Postpaid_file or die "cannot open $Postpaid_file: +$!\n"; while (my $cdr_post_line = <$POST>) { chomp $cdr_post_line; my @cdr_post_array = split /\|/, $cdr_post_line; if ('Submit' eq $cdr_post_array[9]) { if ('GSM' eq $cdr_post_array[12]) { $cdr_post_MO_cnt++ if any { /^\Q$cdr_post_array[11]\E$ +/ } @MOresp_error; $Total_GSM_attempts++ unless any { /^\Q$cdr_post_array +[11]\E$/ } @MOresp_error; if (any { $_ eq $cdr_post_array[13] } qw( GSM ESMEGW ) +) { $total_MT_P2P++ unless any { /^\Q$cdr_post_array[1 +1]\E$/ } @MOresp_error; $total_MT_P2P_success++ if 'Delivered' eq $cdr_pos +t_array[7]; } } elsif ('SMPP' eq $cdr_post_array[12] && '0' eq $cdr_post +_array[10]) { $cdr_post_AO_cnt++; #if any { /^\Q$cdr_post_array[11 +]\E$/ } @MOresp_error; $total_AO_success++ unless any { /^\Q$cdr_post_array[1 +1]\E$/ } @MOresp_error; $Total_SMPP_attempts++ unless any { /^\Q$cdr_post_arra +y[11]\E$/ } @MOresp_error; } } } }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

In reply to Re^5: Need help with Text::CSV by choroba
in thread Need help with Text::CSV 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.