Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2015-10-10 18:28 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (257 votes), past polls