in reply to on Date Change Question

How can add a statement that says if $date_listed (sampledate: 05/29/03) changes write values to anoter textfile then reset all variables ($NumOfFiles,$PlacementDollar,$CurrBal) and start counting again until date changes agian and so on until End Of File.

Just keep track of the last-read date in a variable, and each time through the loop compare. If it's different from the date you just read, do all the stuff you want and update the last-read date.

while (<REPORT>) { my $line = $_; # Is this assignment really needed? ($accnt_num, $date_listed, $disposition, $client, $cancel_reason, $amt_paid, $initial_bal, $accnt_bal) =split /","/; if ($date_listed ne $last_date) { write_values_to_another_textfile(); reset_all_variables(); $last_date = $date_listed; } if ($disposition eq "3DL0" or $disposition eq "3DL1") { $NumOfFiles += 1; $PlacementDollar += $initial_bal; $CurrBal += $accnt_bal; } }

Depending on your circumstances, you may want to reverse the order of the two if sections, so that the summing is done before the resetting. Or not. I'd have to understand more of the context of what you're doing to say for sure.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/