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:

sub recurse { my ($param1, $param2, ...., $aPath) = @_; $id = getIdOfCurentNode(); .... do some stuff ... if ($bNeedToRecurse) { push @$aPath, $id; recurse($param1, $param2, .... $aPath); pop @$aPath; } elsif ($bSomeProblemFound) { print "Error Blah found at node=<@$aPath>\n"; } }

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 reply to Re: Traversing arbitrarily deep and baggy structures by ELISHEVA
in thread Traversing arbitrarily deep and baggy structures by anonymized user 468275

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.