Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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 http://search.cpan.org 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998230]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-12-25 15:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls