|
|
| Perl Monk, Perl Meditation | |
| PerlMonks |
Re^3: Array to hash converstionby spazm (Monk) |
| on Jul 15, 2009 at 06:23 UTC ( [id://780174]=note: print w/replies, xml ) | Need Help?? |
|
I believe this is your question:
"I have an array (@data_list) containing hash references. Each hash reference contains two keys, 'key' and 'value'. I want to turn this into one hash containing 'key'=>'value' pairs. How can I do this?" My solutions below assume that you have unique key values, or are un-interested in collisions. In the case of a collision, the last reference to the key wins. Here is a fully verbose version:
A shorter version: And how do we know they work? We test them. Full version with tests:
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||