XML::Twig print to file gives expected results except for failure return value
From: Henry Law (lawshouse.public_at_btconnect.com)
Date: 04/25/04
- Next message: Asier: "PAR, pp and script packing"
- Previous message: Sisyphus: "Re: Downloading win32 modules for 5.8"
- Next in thread: Michel Rodriguez: "Re: XML::Twig print to file gives expected results except for failure return value"
- Reply: Michel Rodriguez: "Re: XML::Twig print to file gives expected results except for failure return value"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Apr 2004 14:58:46 +0100
(I had some conversation in c.l.p.m about this originally but it's no
longer a Perl coding problem so I'm moving it here.)
Using XML::Twig I'm reading in an XML file, adding an element to it
and writing the result out again. The file is correctly written, but
the return code from the "print" method denotes failure. The Twig
documentation doesn't indicate that behaviour; can someone help me
debug this further?
--------- code to show the error ----------
use strict;
use warnings;
use XML::Twig;
# Get the XML file
my $fdtwig = new XML::Twig;
$fdtwig->parsefile('F:\p\XMLin.XML');
my $fd = $fdtwig->root;
# Create a new twig and paste it into the XML doc
my $stuff = "somestuff";
my $elt = new XML::Twig::Elt('stuff',$stuff);
$elt->paste('last_child',$fd);
# Write the modified XML document to a new file
open XMLOUT, '>F:\p\xmlout.xml';
$fdtwig->print(\*XMLOUT) or
die "Failed to write modified XML file:$!\n";
close XMLOUT;
------------------------------
The result of this (running with ActiveState Perl 5.8.2) is
F:\p>perl tryit.pl
Failed to write modified XML file:Bad file descriptor
But the file "xmlout.xml" is correctly created with the expected
contents. I debugged the program and verified that the return value
is "false".
Henry Law <>< Manchester, England
- Next message: Asier: "PAR, pp and script packing"
- Previous message: Sisyphus: "Re: Downloading win32 modules for 5.8"
- Next in thread: Michel Rodriguez: "Re: XML::Twig print to file gives expected results except for failure return value"
- Reply: Michel Rodriguez: "Re: XML::Twig print to file gives expected results except for failure return value"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]