nitinep has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl saints
I have a program that runs with no glitches on windows on ActiveState Perl 5.6 but on Solaris 8 with Perl 5.8 throws the following error:
Can't locate object method "new" via package "XML::SAX::PurePerl" at /software/perl/5.8.0/lib/site_perl/5.8.0/XML/SAX/ParserFactory.pm line 43.
My code is :
use strict; use XML::Simple; use NET::Telnet; my $xmlobj = XML::Simple->new(); my $xmldoc = $xmlobj->XMLin('./sample.xml'); .... etc etc.........

What can be the reason behind that error ?

nitin

Replies are listed 'Best First'.
Re: XML::Simple on Solaris 8
by grantm (Parson) on Dec 08, 2004 at 01:12 UTC

    The error comes from XML::SAX::ParserFactory which is part of the XML::SAX distribution, so you obviously have that installed. Mysteriously, although XML::SAX::PurePerl is part of the same distribution, it clearly isn't working. You might want to try re-installing XML::SAX and look carefully for error messages during the install.

    Some CPAN modules can be installed by simply copying the .pm files from the distribution tar file into a Perl lib directory (eg: this works for XML::Simple). XML::SAX is not one of those modules. It has magic stuff happening in the Makefile.PL that generates some .pm files on the fly.

    Another thing to beware of is that XML::SAX::PurePerl relies on XML::SAX::Base which is a distribution nested inside the XML::SAX distribution. Running 'make' would normally recurse down into the nested directory but maybe that didn't happen on your system. Try cd'ing into XML-SAX-Base and running 'perl Makefile.PL; make test' there.

Re: XML::Simple on Solaris 8
by runrig (Abbot) on Dec 07, 2004 at 22:00 UTC
    XML::Simple requires an XML parser. The XML::SAX::PurePerl parser is the slowest, but it might be good enough for your purposes. There are also the expat and libXML C libraries (libXML is considered faster, expat is older and considered very stable). Anyway, you will need a working XML::Parser with expat, or XML::SAX with XML::LibXML (with libXML) or XML::SAX::Expat (with expat) or XML::SAX::PurePerl.

    ActiveState installs an XML parser with its distribution, so that's why it works there with no extra effort.

Re: XML::Simple on Solaris 8
by leriksen (Curate) on Dec 08, 2004 at 00:09 UTC