Maybe im totally missing the point, but the following will traverse a tree composed of hashes and return the path.
sub path_to_op { my ($node,$tgt,$path)=@_; $path||=''; return $path if $node==$tgt; foreach my $key (keys %$node) { my $path=path_to_op($node->{$key},$tgt,"$path{$key}"); return $path if $path; } return '' }
But this seems so blindingly obvious to me that I'm having trouble believing I understand the question. After all I know you are very competent programmer so im at a loss to accept that I understand the question correctly....
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
In reply to Re: Logic programming without using the RE engine as a crutch
by demerphq
in thread Logic programming without using the RE engine as a crutch
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |