sub Build_totals_shares_for_sedol_Sell_side($$$) { #$j = shift; my $sedol = shift; my $shares = shift; $condition = ""; my $mySellfirstflag = shift; if ($mySellfirstflag eq "YES") { my $j = 0; } else { my $j = 1;} print "$sedol $shares\n"; $count = 0; if ($j == 0) { %Sellhash = ($sedol => $shares); #print "$Sellhash{key} \n"; foreach $sedolelement (keys %Sellhash) { print "Sell: The $sedolelement has traded\n"; foreach (@{$Sellhash{$sedolelement}}) { print "$_\n"; } } #$NumTradingSedols = 1; } else { #print "this is j $j\n"; foreach $sedolelement (keys %Sellhash) { #print "the key is: $sedolelement te sedol is $sedol\n"; if ($sedolelement eq $sedol) { $condition = "TRUE"; print "the sedol is in the list so add the shares.\n"; $usekey = $sedolelement; $oldshares = $Sellhash{$sedolelement}[1]; } else { $condition = "FALSE"; $count++; } } if (($condition eq "FLASE") && ($count != 0)) { $Sellhash{"$sedol"} .= $shares; print "the new entry is $sedol $shares\n"; } else { $Sellhash{"$sedol"} = $Sellhash{"$sedol"} + $shares; $newtotal = $Sellhash{"$sedol"}; print "the new total shares for sedol: $sedol is $newtotal\n"; } foreach $sedolelement (keys %Sellhash) { $total = $Sellhash{"$sedolelement"}; } } }