There's usually better ways of achieving one's goals. We could help you better if we knew what you were actually trying to do.
I have used symbolic references to simulate linked lists. For example:
sub _create_node { my ($node,$parent,$node_info) = @_; no strict; @{$node}{qw/parent info/} = ($parent,$node_info); }
This way, each node is a hash with the name of its parent under the key "parent" and the info related to the node under the key "node_info". To go through a node:
sub go_through { no strict 'refs'; my ($self, $node) = @_; return "" unless defined ${$node}{"info"}; my @info_nodes; while (${$node}{"info"} ne "root"){ push @info_nodes, (${$node}{"info"}); $node = ${$node}{"parent"}; } return \@info_nodes; }
This runs very fast and doesn't need too much memory
citromatik
In reply to Re^2: Invoke sub whose name is value of scalar
by citromatik
in thread Invoke sub whose name is value of scalar
by andreas1234567
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |