foreach $sedolelement (keys $tradedatehash{$tradedatemarker}) { #### # ------ Build_tradedatehash_sedolandtotalsharesarray ----- sub Build_tradedatehash_sedolandtotalsharesarray($$$$) { #$j = shift; my $tradedate = shift; my $sedol = shift; my $shares = shift; $condition = ""; my $myfirstflag = shift; if ($myfirstflag eq "YES") { my $j = 0; } else { my $j = 1;} print "$tradedate $sedol $shares \n"; $count = 0; if ($j == 0) { $tradedatehash{$tradedate} = {$sedol => $shares}; foreach $tradedatemarker (%tradedatehash) { print "For the date: $tradedatemarker \n\tsedols \t total shares\n\n"; foreach $sedolelement (keys $tradedatehash{$tradedatemarker}) { print "\t $sedolelement \t $_\n"; } print "\thave traded.\n"; } } else { #print "this is j $j\n"; foreach $tradedatemarker (${$tradedatehash{$tradedate}}) { if (exists $tradedatehash{%tradedate}) { print " yes yes yes $tradedatemarker\n!"; foreach $sedolelement (keys $tradedatehash{$tradedatemarker}) { if (exists $sedol) { $tradedatehash{$trademarker}->{$sedol} += $shares; } else { $tradedatehash{$trademarker} = {$sedol => $shares}; }# } } else { $tradedatehash{$tradedate} = {$sedol => $shares}; } } foreach $tradedatemarker (${$tradedatehash{$tradedate}}) { print "For the date: $tradedatemarker \n\tsedols \t total shares\n\n"; foreach $sedolelement (keys $tradedatehash{$tradedatemarker}) { print "\t $sedolelement \t $_\n"; } print "\thave traded.\n"; } } } # end sub Build_tradedatehash_sedolandtotalsharesarray