|Problems? Is your data what you think it is?|
Re^3: Copying a hash to an array of hashes.by Joost (Canon)
|on Sep 18, 2009 at 23:41 UTC||Need Help??|
Perl references are a bit unintuitive, especially when combined with list context.
The main problem you're running into is that putting a hash in list context gives you a flat list containing the keys and values of the hash interleaved, so:
Now @list (*) will contain either ('a',1,'b',2) or ('b',2,'a',1)
@list2 will contain (1,2,3,4).
But references will not be subject to flattening.
I strongly recommend the Camel book for anyone interested in the truth on perl, straight from the horse's mouth. Especially if they're already past the easy stuff. It's not the easiest book but it reads well and for an all round reference and "concept" book on perl, you can't beat it.
(*) please don't ask me about the differences between lists and arrays, it's subtle. forget it for now.