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

Thanks for reply.

At the end, I would expect 3 histograms with the keys being elements of the array and values equal to the count.

line = "0 1 6 2 68fd1e64 80e26c9b 1f89b562 e5ba7672"

0 is the variable for the switch, the rest of the line needs to be put into keys and then count/increment.

hist1={ "0" => 43, "0468d672" => 1, "05db9164" => 7, "07c540c4" => 2, "0a519c5c" => 1, "0b153874" => 14, "1" => 11, "10" => 1, "14" => 1, "15" => 1, "18" => 1, "1e88c74f" => 2, "1f89b562" => 3, "2" => 9, "241546e0" => 1, "287130e0" => 1, "287e684f" => 1, "2c16a946" => 2, } hist2={ "6c9c9cf3" => 1, "7" => 2, "776ce399" => 4, "7cd19acc" => 1, "8" => 1, "80e26c9b" => 2, "8cf07265" => 2, "8efede7f" => 1, "9b5fd12f" => 1, "ad4527a2" => 1, "ae46a29d" => 1, "b0660259" => 1, "bc6e3dc1" => 1, "be589b51" => 1, "d4bb7bd8" => 3, "d833535f" => 1, "e5ba7672" => 7, "f0cf0024" => 2, } hist3={ "3" => 2, "31" => 1, "3486227d" => 1, "361384ce" => 1, "37e4aa92" => 1, "38a947a1" => 1, "38d50e09" => 1, "3c9d8785" => 1, "4" => 3, "439a44a4" => 1, "5" => 3, "510b40a5" => 1, "5a9ed9b0" => 1, "6" => 1, "64523cfa" => 1, "68fd1e64" => 5, }

Replies are listed 'Best First'.
Re^5: Hashes, keys and multiple histogram
by Laurent_R (Canon) on Aug 17, 2014 at 13:27 UTC
    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.