in reply to Re^4: Need help with Text::CSV
in thread Need help with Text::CSV

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; } } } }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^6: Need help with Text::CSV
by ravi45722 (Pilgrim) on Oct 30, 2015 at 04:06 UTC

    It's very helpful choroba. And the execution times also decreased. Thanks a lot