Problems? Is your data what you think it is? | |
PerlMonks |
Re: Traversing arbitrarily deep and baggy structuresby ELISHEVA (Prior) |
on Feb 16, 2011 at 18:47 UTC ( [id://888550]=note: print w/replies, xml ) | Need Help?? |
I'd like to second ikegami's suggestion and recommend that you take a serious look at Xpath and XSLT. There isn't much point in writing your own pattern matcher when there is a really good one out there already. XSLT can be used to transform the document once you've found the nodes of interest. However, in order to use them, you'll need to understand your document's structure, so perhaps that is putting the cart before the horse. I devised an addressing mechanism as : { treetop => $arrayref, immedparent => $someref, ixork => $ArrayIndexOrHashKey } I'm not sure I understand your addressing scheme - are you pairing elements (node, immediate parent)? When I traverse arbitrarily deep structures I usually use a simple array to store the descent path, like this:
it takes ages to step my way through with the debugger to find out why my search routines don't do anything useful. Although I feel a bit awkward about pushing my own modules, I'd also like to suggest a module that I recently released on CPAN, Exception::Lite. I wrote it because I do a lot of recursive programming and needed a better way to see the stack when there is an error in my code. I too found walking through a debugger tedious and way too time consuming.
In Section
Seekers of Perl Wisdom
|
|