http://qs321.pair.com?node_id=1143002


in reply to Re: extracting elements by key from an array of hashes
in thread extracting elements by key from an array of hashes

True that. However, the data is coming from an xmlrpc source via XML::RPC and that's how it's structured. I don't have control over the source API or at least I don't want to change it.

  • Comment on Re^2: extracting elements by key from an array of hashes

Replies are listed 'Best First'.
Re^3: extracting elements by key from an array of hashes
by choroba (Cardinal) on Sep 25, 2015 at 10:35 UTC
    You can easily create a temporary hash to do the searches:
    my %hash = map %$_, @rpc;
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^3: extracting elements by key from an array of hashes
by davido (Cardinal) on Sep 25, 2015 at 14:57 UTC

    Keep in mind that you have no obligation to store data internally in inconvenient formats. If it is more convenient to manipulate it internally as a hash, do that conversion at the earliest possible point after reading it in, and convert back at the latest possible point if you ever have to output the structure again.


    Dave

Re^3: extracting elements by key from an array of hashes
by Anonymous Monk on Sep 25, 2015 at 10:45 UTC
    ... and if there is potentially more than one value per bucket, simply make each element an arrayref. Auto-vivification makes this trivially easy to do.