if ($mySellfirstflag eq "YES") { %Sellhash = ($sedol => $shares); #Do you mean that with mySellfirst that we should replace the shar +es, #If so, the above line should be $Sellhash{$sedol}=$shares. #As it stands now, we replace the entire hash!!