in reply to storing and using LoL path
The answer is either simple or complicated, and in either case it is likely that you are asking the wrong question. Provide a little more context for the problem and we may be able to help with a more appropriate solution. Meanwhile:
In the simple case where the paths are constant and the references in the data structures are not being changed %map simply holds references to the leaf nodes of interest.
In the complicated case where %map holds templates for access paths where some of the node index values may change you probably need a recursive sub to do the work. In this case it may help if $lol were an object.
Note that the simple case of using a reference to the desired node is appropriate where you want to avoid repeating the same tiresome access path into a complicated structure many times in the same context. For example:
my $lol = [[{pigs =>'fly'}, [1, 2, 3], {apples => [qw(red green yellow +)], oranges => [orange]}]]; my $oranges = $lol->[0][2]{oranges};
Note: code not tested
|
|---|