Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by ciderpunx (Vicar)
on Sep 25, 2015 at 10:06 UTC ( [id://1143002]=note: print w/replies, xml ) Need Help??


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.

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1143002]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-28 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found