Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Buggy output from XML::Twig on a Tee

by mr_ron (Chaplain)
on Feb 26, 2016 at 16:25 UTC ( #1156238=note: print w/replies, xml ) Need Help??


in reply to Buggy output from XML::Twig on a Tee

I don't use stackoverflow much and couldn't comment there, which might have been more appropriate, but I took Ikegami's solution to your stackoverflow post and modified it just a little as below and the result seemed to do what you wanted with one pass.

my $tee = IO::Tee->new($frufile, $vegfile); my $twig = XML::Twig->new( ... etc. twig_print_outside_roots => $tee, ... ); $twig->parse( *DATA );
Ron

Replies are listed 'Best First'.
Re^2: Buggy output from XML::Twig on a Tee
by seki (Monk) on Mar 01, 2016 at 16:04 UTC

    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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2022-12-07 20:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?