J
Jeff.M
I've been getting a very weird bug. No error message. perl simply
crashes. With lots of trial and error, I've narrowed down the parts
that cause the crash. Below is some very simple code that -- on my
WinXP comp with ActivePerl 5.8.8 -- will crash reliably.
use strict;
use warnings FATAL => 'all';
use XML::LibXML;
use LWP::Simple;
# The XML structure...
# <myroot>
# <somenode>
# <somedeepernode>Hello, World!</somedeepernode>
# </somenode>
# </myroot>
my $rootNode = XML::LibXML::Element->new('myroot');
my $someNode = XML::LibXML::Element->new('somenode');
$rootNode->appendChild($someNode);
my $someDeeperNode = XML::LibXML::Element->new('somedeepernode');
$someDeeperNode->appendText('Hello, World!');
$someNode->appendChild($someDeeperNode);
my @someNodes = $rootNode->getElementsByTagName('somenode');
foreach my $someNode (@someNodes)
{
# If this line is commented, then all is good.
# But if it's left in... crash.
my $theText = $someNode->findvalue('somedeepernode');
# This line -- a different way to accomplish
# the same thing -- would crash too.
# my $theText = $someNode->getElementsByTagName('somedeepernode')-
# Or if this line is commented, then all is good also. But because
I've had
# other weirdness with getting text from XML nodes, I'm leaning toward
LibXML
# being the culprit.
my $x = get('http://www.perl.com');
print q`If you're reading this, then it worked!`;
crashes. With lots of trial and error, I've narrowed down the parts
that cause the crash. Below is some very simple code that -- on my
WinXP comp with ActivePerl 5.8.8 -- will crash reliably.
use strict;
use warnings FATAL => 'all';
use XML::LibXML;
use LWP::Simple;
# The XML structure...
# <myroot>
# <somenode>
# <somedeepernode>Hello, World!</somedeepernode>
# </somenode>
# </myroot>
my $rootNode = XML::LibXML::Element->new('myroot');
my $someNode = XML::LibXML::Element->new('somenode');
$rootNode->appendChild($someNode);
my $someDeeperNode = XML::LibXML::Element->new('somedeepernode');
$someDeeperNode->appendText('Hello, World!');
$someNode->appendChild($someDeeperNode);
my @someNodes = $rootNode->getElementsByTagName('somenode');
foreach my $someNode (@someNodes)
{
# If this line is commented, then all is good.
# But if it's left in... crash.
my $theText = $someNode->findvalue('somedeepernode');
# This line -- a different way to accomplish
# the same thing -- would crash too.
# my $theText = $someNode->getElementsByTagName('somedeepernode')-
}get_node(1)->nodeValue;
# Or if this line is commented, then all is good also. But because
I've had
# other weirdness with getting text from XML nodes, I'm leaning toward
LibXML
# being the culprit.
my $x = get('http://www.perl.com');
print q`If you're reading this, then it worked!`;