Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: creating large xml files

by holli (Monsignor)
on Jun 22, 2006 at 10:57 UTC ( #556881=note: print w/replies, xml ) Need Help??


in reply to creating large xml files

I am creating large xml files via the Template Toolkit and the output directive hack. Works like a charm.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: creating large xml files
by tinita (Parson) on Jun 22, 2006 at 16:00 UTC
    can't you just output to a filehandle? (note that I'm not a TT expert, I'm just wondering)
      Hey tinita! Nice to hear from you. I gonna be in Berlin for the world cup finals. I'd like to see you again. But back to the technical stuff:

      You can specify an ouput file when calling process(), but that doesn't solve the memory problem, because the whole output will still be concatenated to a single string. Atm the only way to make TT to print directly is to use the "hack" mentioned above. However if you need to print to an output file you can use this:
      use warnings; use strict; use Template; use Template::Directive; $Template::Directive::OUTPUT = 'print $main::OUT '; our $OUT; open $OUT, ">", "output.txt"; my $tmpl = Template->new(); my $text = "<test>[%data%]</test>"; $tmpl->process (\$text, {data=>'xxx'}); close $OUT;


      holli, /regexed monk/
      hi holli =)

      I didn't know that the string isn't printed immediately in TT. In HTML::Template::Compiled, for example, it is.

      p.s.: message me when you're in Berlin.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2019-12-06 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (156 votes). Check out past polls.

    Notices?