in reply to How to use 2 files for calculating charges
and then add them into your $amt calcopen PREV,'<','prev.txt' or die "$!"; my %prev_days=(); #BIGCO-C CMO 180304 L 6/30/13 2 while (<PREV>){ chomp; my @f = split /\s+/,$_; $prev_days{$f[2]} = $f[5]; }
pojwhile (<$file>) { my @f = split '\s+', $_; $cnt++; # fill empty dates with month end my @ymd1 = split ',',$f[4] //= $prev_mth_end; my @ymd2 = split ',',$f[5] //= $prev_mth_end; my $diff = Delta_Days(@ymd1, @ymd2); my $prev = $prev_days{$f[2]} //= 0; my $amt = ($diff + $prev > 3) ? $diff + $prev - 3 : 0; my $cost = ($amt * 100); my $pfmt = "%-14s %-5s %-8s %-3s %-12s %-12s %-6s %-6s %-6s %-6s\n"; printf OUT $pfmt, @f[0..3], fmt_mdy($f[4]), fmt_mdy($f[5]), $diff, $ +amt, fmt_curr($cost), $prev; }
|
|---|