in reply to XML::Twig Question
There are 2 ways to do this:
my $data= $twig->sprint; print OUT $data;
or
$twig->print( \*OUT)A simple $twig->print prints to the standard output (or whatever filehandle is select-ed at the time).
Just in case... note that you shouldn't use bareword as filehandles, but rather variables as in:
open( my $out, '>pretty.xml') or die "can't open pretty.xml: $!"; # +perl 5.6.*
or
open( my $out, '>', 'pretty.xml') or die "can't open pretty.xml: $!" +; # perl 5.8.*
Perl's Best Practice has a very good explanation of the reasons for this, but in a nutshell, OUT is a global variable, which is bad.
|
|---|