Subject: | Example Files from XML::Twig Web Page Don't Work |
I'm getting the following error:
Use of uninitialized value in null operation at C:/Perl/site/lib/XML/Parser/Expat.pm line 438.
Undefined subroutine &main:: called at C:/Perl/site/lib/XML/Parser/Expat.pm line 438.
when I execute the sample script:
ex1_6.pl
This sample script is from the tutorial at:
http://standards.ieee.org/resources/spasystem/twig/tutorial/index.html
Hmmm, the script seems to have been removed from that page . . .
Here are the contents of the script:
-----------------
#!/bin/perl -w
#########################################################################
# #
# This example shows how to use the TwigRoots option #
# It outputs the name of the leader in a statistical category #
# #
#########################################################################
use strict;
use XML::Twig;
my $leader_name;
my $leader_score=0;
my $field= $ARGV[0] || 'ppg';
# twig will be created only
# for name and $field elements
my $twig= new XML::Twig( TwigRoots => { 'name' => 1, $field => 1 },
# handler will be called for
# $field elements
TwigHandlers => { $field => \&field } );
$twig->parsefile( "nba.xml"); # parse the twig
# print the result
print "Leader in $field: $leader_name ($leader_score $field)\n";
sub field
{ my( $twig, $field)= @_;
# get the score
my $score= $field->text;
if( $score > $leader_score) # if it's the highest
{ $leader_score= $score; # store the information
$leader_name= $field->prev_sibling( 'name')->text;
}
$twig->purge; # delete the twig so far
}
-----------------
Here is line 438 from Expat.pm
Expat.pm:438: $result = ParseStream($parser, $ioref, $delim);
The function ParseStream doesn't seem to be defined anywhere, and it doesn't seem to be called anywhere but on that line.
The problem does not occur with XML::Twig 2.02, but does occur with XML::Twig 3.0[123].
Here are the results from running "perl -V":
-----------------
Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEX
T -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
optimize='-O1 -MD -DNDEBUG',
cppflags='-DWIN32'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -release -libpath:"C:\Perl\lib\CORE" -machine:x86'
libpth="C:\Perl\lib\CORE"
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.
lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -libpath:"C:\Perl\lib\CORE" -machine:x86'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
Locally applied patches:
ActivePerl Build 630
Built under MSWin32
Compiled at Oct 31 2001 20:29:41
%ENV:
PERL_BIN="c:\Perl\bin;"
PERL_TOOLS="c:\tools\perltool"
@INC:
c:/Perl/lib
c:/Perl/site/lib
.
-----------------
The command "uname -a" doesn't seem to be supported on my system; I am running Microsoft Windows XP Professional as my operating system.