in reply to Count number of elements in HoH and sum them for other keys

Seems like an exercise in linked list data structure that accounts for multiple occurrences of a value.

For your ideal hash reference structure when you are populating the hash reference, (1) stick a "count" key, value of which is incremented (& starts with 1) just in the manner you would add "B" key of a hash reference value for "A" key; (2) assign the array reference value also a key to have a valid hash reference.

  • Comment on Re: Count number of elements in HoH and sum them for other keys

Replies are listed 'Best First'.
Re^2: Count number of elements in HoH and sum them for other keys
by Anonymous Monk on Jun 03, 2014 at 11:53 UTC

    And to multiply, iterate over the keys, via keys function, of each hash reference to find the count; store them; then multiply. See also "perlref" & "perlreftut" PODs.

      thanks your comments were quite helpful. I read them before seeing the reply of smls below, and was implementing something similar to what he ended up doing. Thanks