Yes, but did you take note of what I said. Parsing XML is hard. Especially if you are new to this stuff: don't reinvent the wheel (see Re: Reinventing the wheel and Re: Reinventing the wheel). Try running the code I supplied. Try running it against a sample of your real data. Skim read the XML::Twig documentation. I know it looks really intimidating, but it contains really good examples and will save you much more time debugging your own hand written XML parsing code than you spend figuring out how to use the module.

On a more general programming style note: "run through the ... multiple times" is almost always a red flag in programming (and most other places too). The more times you have to perform a slow operation the slower the overall job will be. Turn your inner two loops inside out so you read the file once and perform multiple matches per line. Compared with accessing information in memory accessing data from disk is very slow.

True laziness is hard work

In reply to Re^3: I don't understand why I'm getting an "Use of uninitialized value" error by GrandFather
in thread I don't understand why I'm getting an "Use of uninitialized value" error by TheBigAmbulance

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.