Problems with libxml, XML::LibXML and Perl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Gregory

    #1

    Problems with libxml, XML::LibXML and Perl

    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('te st.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_parse r->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!

    --
    Ian Gregory
    Replace "groups" with my first name in my email address to contact me
    directly
  • cp

    #2
    Re: Problems with libxml, XML::LibXML and Perl

    In article <74292ec3.03072 31256.49ccd114@ posting.google. com>, Ian
    Gregory <groups@ians-net.co.uk> wrote:
    [color=blue]
    > $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_parse r->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?[/color]

    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.

    --
    cp

    Comment

    Working...