If you really need a hash, you could always keep the order information in arrays in the hash like this:
$VAR1 = {
'order' => [ 'Foo' ],
'data' => {
'Foo' => {
'order' => [ 'D', 'A', 'E', 'B', 'C' ],
'data' => {
'D' => {
'order' => [ '1' ],
'data' => {
'1' => {}
},
'A' => {},
'E' => {
'order' => [ '1', '2', '3', '4' ],
'data' => {
'1' => {},
'2' => {},
'3' => {},
'4' => {}
}
}
...etc.
Of course, maintaining that structure could be a chore. Java has what you're looking for - a hash that maintains order - it's called a LinkedHashMap. Basically it's a hash with a linked list running through it. <handwaving>I leave the Perl implementation as an exercise for the reader...</handwaving>
Update
Ok, I feel like an idiot. Ignore the Java ramblings - IxHash is the same as a LinkedHashMap. The data structure works, however (even if it is a pain). | [reply] [d/l] |
What I did in Excel::Template was to create a hash as the root node. It has an array (called children) of children nodes, each represented as a hash. And, so forth. Some intelligent coding in the baseclass and everything came together.
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
| [reply] |