in reply to Grouping of 2D arrays

Guessing your question is about the best strategy

You need to

I just noticed you have also a count to accumulate so something like

$product{PC}{Spare} = { count=>2, sum => 37,2}

Is a good structure.

So with which part do you have a problem?

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Grouping of 2D arrays
by AnomalousMonk (Archbishop) on Apr 20, 2017 at 15:06 UTC
    $product{PC}{Spare} = { count=>2, sum => 37,2}

    Doesn't this give an "Odd number of elements..." warning? Maybe something like
        $product{PC}{Spare} = { count=>2, sum => [37, 2] };


    Give a man a fish:  <%-{-{-{-<

      Probably, (for cultural reasons I don't wonder about a comma as fraction separator).

      But as shmem already said, converting to cents is the way to go to avoid rounding errors.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        ... cents ...

        Oh,  37,2 uses the perverse European decimal point! The penny drops...


        Give a man a fish:  <%-{-{-{-<