Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: XPath-like method for searching/editing structures

by sundialsvc4 (Abbot)
on Oct 10, 2012 at 13:32 UTC ( #998230=note: print w/replies, xml ) Need Help??

in reply to XPath-like method for searching/editing structures

As an aside, it can be useful to rig-up a “data walker” object that will iterate through a data-structure ... search for “walker” ... and then perhaps maintain a push-down stack of such objects.   Once, I solved a similar problem by devising a walker that would call a specified sub (coderef ...) when it found a matching node.   Each subroutine in turn made the decisions that needed to be made at that level, and spawned another walker-instance to proceed further.   Thus, the walkers handled the task of navigation while the subroutines made the case-specific decisions.   (It was a lot easier to do than to describe.)   I did it this way because, while I could not predict what the shape and depth of the structure would be, I could describe the logic as a small number of reusable, node-specific cases.

  • Comment on Re: XPath-like method for searching/editing structures

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998230]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2017-12-17 21:44 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (466 votes). Check out past polls.