S
sabio62
G'Day,
I've got some trouble with not being able to access the data being
returned from a sub; the sub in question is supposed to return a
reference to an array of Multinode::Tree::Handle objects.
The problem is evident inside the sub itself. The sub contains a
recursive sub which in turn is updating an array beloning to the main
sub ...
I'd greatly appreciate if you can take a look at it and let me know
what to do get the handles properly ...
You may access the source code from this link:
http://www.geocities.com/sabio62/perl/build_categories_tree_with_a_hash_as_values_01.pl.txt
Some background on what I'm trying to do ...
I'm trying to build a tree that may have nodes with repeated keys in
it. For a particular key, I would like to be able to graft children
to the tree at all instances of that key.
For this purpose I've got a sub called add_children_to_str_key
that takes as parameters the string key, a hash containing the
children data to be inserted into the tree for the nodes matching the
string key, a tree object, and an optional handle to the tree, which
if given, we may start the search at that particular handle, otherwise
we start from the top of the tree.
Now, this sub add_children_to_str_key calls a recursive sub named
get_handles_on_string_key which is supposed to search the tree for all
keys that match the string key and return a reference to an array of
tree handles, which is done by matching the current handle's key,
creating a new handle, assigning it to the current handle and pushing
it onto the @found_handles, which is to be returned upon completion of
the recursion ...
Now, the problem that I'm getting is that I'm unable to get the
key/value pair from elements of the array of Tree::MultiNode::Handle's
once the recursive function has completed. The handles are there, and
they match exactly what I see inside the recursive search, but the
values upon completion via get_key, get_value or get_data, just aren't
there ... essentially 'undefined'. However, inside the recursive sub
(preorder_traverse_str_key_search) when I get a match for the key an
create a new handle and assign it it to the current handle the
key/value pairs are there ...
I take it that this has _nothing_ to do with MultiNode.pm per se, and
is more likely to be how I'm coding this stuff.
Any ideas greatly appreciated.
TIA,
Cheers, Sabio
I've got some trouble with not being able to access the data being
returned from a sub; the sub in question is supposed to return a
reference to an array of Multinode::Tree::Handle objects.
The problem is evident inside the sub itself. The sub contains a
recursive sub which in turn is updating an array beloning to the main
sub ...
I'd greatly appreciate if you can take a look at it and let me know
what to do get the handles properly ...
You may access the source code from this link:
http://www.geocities.com/sabio62/perl/build_categories_tree_with_a_hash_as_values_01.pl.txt
Some background on what I'm trying to do ...
I'm trying to build a tree that may have nodes with repeated keys in
it. For a particular key, I would like to be able to graft children
to the tree at all instances of that key.
For this purpose I've got a sub called add_children_to_str_key
that takes as parameters the string key, a hash containing the
children data to be inserted into the tree for the nodes matching the
string key, a tree object, and an optional handle to the tree, which
if given, we may start the search at that particular handle, otherwise
we start from the top of the tree.
Now, this sub add_children_to_str_key calls a recursive sub named
get_handles_on_string_key which is supposed to search the tree for all
keys that match the string key and return a reference to an array of
tree handles, which is done by matching the current handle's key,
creating a new handle, assigning it to the current handle and pushing
it onto the @found_handles, which is to be returned upon completion of
the recursion ...
Now, the problem that I'm getting is that I'm unable to get the
key/value pair from elements of the array of Tree::MultiNode::Handle's
once the recursive function has completed. The handles are there, and
they match exactly what I see inside the recursive search, but the
values upon completion via get_key, get_value or get_data, just aren't
there ... essentially 'undefined'. However, inside the recursive sub
(preorder_traverse_str_key_search) when I get a match for the key an
create a new handle and assign it it to the current handle the
key/value pairs are there ...
I take it that this has _nothing_ to do with MultiNode.pm per se, and
is more likely to be how I'm coding this stuff.
Any ideas greatly appreciated.
TIA,
Cheers, Sabio