Q&A > Data Structures
Description:
I have an array of hashes:Can I tie the hashes to retrieve their values in insertion order?push @data { yo => mama, bliz => at }
Answer: How do I tie an array of hashes? contributed by Fastolfe The items in your array are in insertion order, so what remains is each individual hash. In your example above, you have a list with one element: a standard hashref. Since you can't "tie" an anonymous reference like this, you would need to use the object-oriented abilities of Tie::IxHash instead: You can also create separate hashes, tied to Tie::IxHash (per the man page) and push references to each of those tied variables onto @data. |
Please (register and) log in if you wish to add an answer
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |