Hi All, I am stuggling with creating a script that will take the value from a field on each line where the account number is the same and add them together. There will never be more than two lines per account number. End result would be to take the value in field 5 where acct# number is the same and print out 1 new line for each Acct# with the combined value. I can get the acct#, cusip and values. Just cant seem to figure out how to add them together. Any help will be greatly appreciated.
Changed code a bit, problem I get now is $recs{$ACTNUM} += $CSH_TRD_BAL2 ; increments. Even if Actnum only exist once the value is incorrect. I want to get print out the actnum once with the combined value of $CSH_TRD_BAL2 for a single account number:
ACTNUM,VALUE
my %recs =();
while (<inData>) {
chomp;
$line = $_;
next unless ($line =~/^DTL/);
$CUSIP = substr $line, 4, 12;
$CUSIP =~s/\s+//g;
$ACTNUM = substr $line, 240, 9;
$CSH_TRD_BAL = substr $line, 64, 17;
$CSH_TRD_BAL2 = substr $line, 64, 17;
$recs{$ACTNUM} += $CSH_TRD_BAL2 ;
&GetCusip("$CUSIP");
print "$recs{$ACTNUM} $CSH_TRD_BAL2 $CUSIP $ACTNUM\n " if ($CUSCOD
+E eq 'MMKS');
}