in reply to Logic programming without using the RE engine as a crutch
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Logic programming without using the RE engine as a crutch
by diotalevi (Canon) on Jun 30, 2004 at 17:38 UTC | |
by demerphq (Chancellor) on Jun 30, 2004 at 17:48 UTC | |
|
Re^2: Logic programming without using the RE engine as a crutch
by Anonymous Monk on Jul 02, 2004 at 15:20 UTC | |
by Anonymous Monk on Jul 02, 2004 at 15:23 UTC |