in reply to Re^4: Hashes, keys and multiple histogram
in thread Hashes, keys and multiple histogram

Then I think you really need exactly what I suggested in my second answer. Replace your code by the following one for each of your three hashes:
$hash1{$_}++ for @elements;
(changing obviously to the right hash name depending on the switch variable) and I think it should do the trick.