yes the answer of Ikegami (using the twig_roots instead of the twig_handlers) produce a result as asked, in a single pass.

But it is not the solution that I will use because of some additional needs :p : in the 'common' part of the produced files, an identifier need to be different in each file, thus when parsing that identifier with XML::Twig, I cannot presume of the value to put in, because I do not know the number of final files.

It results in a complicated program where I need to keep the beginning of the file in memory to let it be updated differently each time I write a chunk of <thing> in a separate file, while not keeping all the <thing>'s in memory because of the quantity of data... I am tweaking an XML::SAX::Writer based solution instead.


In reply to Re^2: Buggy output from XML::Twig on a Tee by seki
in thread Buggy output from XML::Twig on a Tee by seki

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.