Problems with libxml, XML::LibXML and Perl

I

Ian Gregory

Hi,

One of our servers has recently been upgraded and as a result both
libxml and XML::LibXML have been upgraded. The OS is OpenBSD 3.3.
libxml has gone from version 2.4.18 to 2.5.7p1 and XML::LibXML from
1.40 to 1.54

However, since the upgrade, XML::LibXML seems to be affecting Perl's
file handling in ways it shouldn't. The following example illustrates
this:

-----------------

$cat test.pl
#!/usr/bin/perl -w

use strict;

use XML::LibXML;

my $xml_parser=XML::LibXML->new();

#This breaks things in an interesting way
my $style_doc=$xml_parser->parse_file('test.xml');

print "1\n";
open(FOO,">foo.txt") or die ("Can't open");
print "2\n";
print FOO "test\n" or die ("Can't print");
print "3\n";
close FOO or die ("Can't close: $!");
print "4\n";

$cat test.xsl
<?xml version="1.0"?>
<foo>
<bar />
</foo>


$./test.pl
1
2
3
Can't close: Bad file descriptor at ./test.pl line 18.

-----------------

The file foo.txt is created but is empty. Commenting out the
"$xml_parser->parse_file" line leads to the script giving the expected
output (foo.txt contains "test" and 1234 is printed)

I've looked through the relevant changelogs but I can't see anything
which would lead to this problem. Has anyone else experienced this
kind of problem?

Thanks in advance!
 
C

cp

Ian said:
$cat test.xsl
<?xml version="1.0"?>
<foo>
<bar />
</foo>


$./test.pl
1
2
3
Can't close: Bad file descriptor at ./test.pl line 18.

-----------------

The file foo.txt is created but is empty. Commenting out the
"$xml_parser->parse_file" line leads to the script giving the expected
output (foo.txt contains "test" and 1234 is printed)

I've looked through the relevant changelogs but I can't see anything
which would lead to this problem. Has anyone else experienced this
kind of problem?

Worked fine for me:
[Chris:~/scripts] cpryce% perl LibXML_test.pl
1
2
3
4
[Chris:~/scripts] cpryce% cat foo.txt
test

Perhaps, on your operating system you need to make sure that you've
flushed the buffer?

Try setting $| = 1; before printing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top