in reply to Re^2: remapping an arrayref of hashrefs to a hashref of array refs
in thread remapping an arrayref of hashrefs to a hashref of array refs

Using native Perl isn't "re-inventing wheels". Larry invented the wheels many years ago, your just using them.

Any api you or anyone devised to perform that operation would of necessity be either:

  1. So specific to that operation, that it would have no other use than that single operation.

    It would have to be called something like:

    sub createHoAoHfromAoHbyIndexingByTheValueOfOneKey{ my( $AoHref, $key ) = @_; ### About 20 lines of parameter checking and error reporting/excep +tion ### handling here. Because unlike doing it in-line, the programmer + writing ### this function cannot know what the caller will pass him. my %HoAoH; push @{ $HoAoH{ delete $_->{ $key } } }, $_ for @$AoHref; return \%HoAoH; }

    And to put that on CPAN, you'd need to wrap it in a package and add tests and documentation and dependencies and all bullshit--and how many times would it ever get used?

    And all of that to replace one, simple, long existing, simple, intuitive wheel.

    All it requires is for you to read the docs and apply a little thought; rather than expecting someone else to do your thinking for you.

  2. The only alternative would be some very generic, nested structure restructuring tool.

    Something that could equally be used to do:createAoHoAfromHoHoAbyTheValueOfOneKeyFromTheHashAndTheValueOfTheThirdElementOfTheSecondArray()

    And any API to do that kind of manipulation would have to be incredibly complex. Because it would essentially have to re-create all Perl's hash and array manipulation possibilities, without the benefit of Perl's very clear, concise and orthogonal syntax.

    And the complexity of any such undertaking would simply be ridiculous to the point of absurdity.

You're not trying to avoid "reinventing wheels", just avoid having to think!


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."