The data structure needs to be hierarchical and support both hashes and arrays. A quick example of what is needed is:
$galaxy{solarsystem}{planet}[year]{lat}{long}=’foo’;
Now, a simple hash of hashes of hashes… takes care of 95% of the requirements. The problem arises when I want to introduce an array as a parent of a hash. I know I can make a hash (of hashes of hashes) and put a reference to it in the array and be done with it. What I would like to do is eliminate some of that complexity so this data structure can be added to without that additional effort. i.e. the above assignment will fail due to pseudo-hashes being depreciated. (Note: they fail because year is an array. If year is a hash, everything is golden.)
An option that I could use is to simply shorten the depth of a majority of the tree such as:
$galaxy{solarsystem.planet}[year]{lat.long};
But I’m not sure if the added complexity in referencing inside foreach and similar loops is worth any speed improvement. I could combine this with converting the year to a hash and end up with a huge single level hash ($galaxy{solarsystem.planet.year.lat.long}) but that kind of defeats the purpose I’m trying to accomplish in the first place.
So.. I’m looking at what seem to amount to three options. First is to go with straight hashes and make sure array indexes are properly handled (which involves rewriting a non-trivial amount of code, but it is code that will probably need to be rewritten anyway). My second option is to implement the data structures ‘properly’ which may cause some confusion to non-programmers. My third option is to look around for or write a module that can load multi-dimensional hierarchal data from a configuration file (probably exists somewhere).
In order of importance, I want to code this to be:
Anyone have any advice?
In reply to Hierarchial data structures by Q3Man
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |