sub debug{ print @_; } #### my %__privateIndexHash; #key = country read, value is allways 1 my @CountryList; sub Build_Country_List($){ #I do not really care about the boolean, Ill figure this out for myself. my $country=shift; if(!exists $__privateIndexHash{$country}){ #Havent seen country before, insert into array and hash index $__privateIndexHash{country}=1; push @CountryList, $country; } } #### my @CountryList; Build_Country_List($){ my $country=shift; push @CountryList, $country unless grep { $_ eq $country} @CountryList; } #### my $total; sub Build_totals_shares_for_sedol_Sell_side($$$) { my $sedol = shift; my $shares = shift; my $mySellfirstflag = shift; if ($mySellfirstflag eq "YES") { %Sellhash = ($sedol => $shares); #Do you mean that with mySellfirst that we should replace the shares, #If so, the above line should be $Sellhash{$sedol}=$shares. #As it stands now, we replace the entire hash!! print "Sell: The $sedol has traded\n$share\n"; } else { if (exists $Sellhash{$sedol}) { print "the sedol is in the list so add the shares.\n"; $Sellhash{"$sedol"} += $shares; my $newtotal = $Sellhash{"$sedol"}; print "the new total shares for sedol: $sedol is $newtotal\n"; } else { $Sellhash{$sedol} = $shares; #You did a .= here was that a typo? print "the new entry is $sedol $shares\n"; } $total=0; $total += $_ foreach values %Sellhash; } }