|laziness, impatience, and hubris|
Re: storing and using LoL pathby almut (Canon)
|on May 25, 2007 at 21:07 UTC||Need Help??|
If I'm understanding you correctly (which I'm not at all sure), what you want is something like could be achieved with the following if/elsif... structure
i.e. with the following minimal sample data
But you think the if/elsif thingy is not perlish enough, would not scale decently up to a gazillion of different types, or some such... (?)
In that case, one other way to do it would be to set up little "accessor" functions (not in the OO sense, thus the quotes), which you would index via the hash, e.g.
In that case, you could write the above loop as
The type would select the appropriate function (via %map), which "knows" how to get at the desired data. The data (i.e.the toplevel ref to some data structure) is passed to the function as argument.
I'm sure that once you confirm this is what you want to do, other Monks will come up with various other solutions... :)