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

Dear Monks,

This script:

use strict; use warnings; use 5.010; use XML::Simple; my $str= '<abc><nested>hello</nested></abc>'; my $xml = XMLin($str);

gives me this error:

Can't load '/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/auto/X +ML/LibXML/LibXML.bundle' for module XML::LibXML: dlopen(/usr/local/li +b/perl5/site_perl/5.10.1/darwin-2level/auto/XML/LibXML/LibXML.bundle, + 1): Symbol not found: _PL_na Referenced from: /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level +/auto/XML/LibXML/LibXML.bundle Expected in: dynamic lookup at /usr/local/lib/perl5/5.10.1/darwin-2level/DynaLoader.pm line 153 BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5. +10.1/darwin-2level/XML/LibXML.pm line 153. Compilation failed in require at /usr/local/lib/perl5/site_perl/5.10.1 +/darwin-2level/XML/LibXML/SAX.pm line 17. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5. +10.1/darwin-2level/XML/LibXML/SAX.pm line 17. Compilation failed in require at (eval 3) line 1.

I thought I installed XML::Simple, so I tried this:

cpan[4]> recent Constant subroutine XML::LibXML::XML_XMLNS_NS redefined at /usr/local/ +lib/perl5/5.10.1/constant.pm line 115, <FIN> line 4. Constant subroutine XML::LibXML::XML_XML_NS redefined at /usr/local/li +b/perl5/5.10.1/constant.pm line 115, <FIN> line 4. Subroutine VERSION redefined at /usr/local/lib/perl5/site_perl/5.10.1/ +darwin-2level/XML/LibXML.pm line 37, <FIN> line 4. no XML::LibXML installed, cannot continue

Ok, so I tried this:

cpan[5]> install XML::LibXML XML::LibXML is up to date (1.70).

Huh?

cpan[6]> recent Constant subroutine XML::LibXML::XML_XMLNS_NS redefined at /usr/local/ +lib/perl5/5.10.1/constant.pm line 115, <FIN> line 6. Constant subroutine XML::LibXML::XML_XML_NS redefined at /usr/local/li +b/perl5/5.10.1/constant.pm line 115, <FIN> line 6. Subroutine VERSION redefined at /usr/local/lib/perl5/site_perl/5.10.1/ +darwin-2level/XML/LibXML.pm line 37, <FIN> line 6. no XML::LibXML installed, cannot continue

Can anyone tell me what the problem is?

Replies are listed 'Best First'.
Re: XML::Simple problems
by Corion (Patriarch) on Feb 10, 2010 at 12:01 UTC

    Most likely, you or your system administrator upgraded libxml and now you need to recompile and reinstall XML::LibXML. The easiest way to do so in my opinion is through the CPAN shell and its look command which drops you in a directory ready for building a module:

    shell> cpan cpan> look XML::LibXML shell> perl -w Makefile.PL shell> make shell> make test shell> make install

      I haven't done anything with XML in scripts for two months, and I haven't installed anything. The only thing I installed recently was the GIMP.

      Also, one of the cpan prompts I posted says XML::LibXML is up to date.

        It doesn't matter whether the version of XML::LibXML installed on your machine is the same (or newer) than the one on CPAN. You need to recompile it to match it up with its prerequisites that changed below it. But feel free to ignore my approach.

        Potentially, the GIMP upgraded some external libraries, like libxml. Review your operating system upgrade logs, and if you want to be sure, restore an old machine state from backup and check against that.

      Ok, I went with your suggestion. My cpan shell did something a little different though, so I'll post the output in case it helps someone else in the future:

      $ sudo perl -MCPAN -e shell Password: Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.9402) Enter 'h' for help. cpan[1]> look XML::LibXML CPAN: Storable loaded ok (v2.20) Going to read '/Users/me/.cpan/Metadata' Database was generated on Wed, 10 Feb 2010 07:46:34 GMT Running look for module 'XML::LibXML' Trying to open a subshell in the build directory... CPAN: YAML loaded ok (v0.70) CPAN: Digest::SHA loaded ok (v5.47) CPAN: Compress::Zlib loaded ok (v2.02) Checksum for /Users/me/.cpan/sources/authors/id/P/PA/PAJAS/XML-LibXML- +1.70.tar.gz ok Scanning cache /Users/me/.cpan/build for sizes ...................................................................... +......DONE CPAN: Archive::Tar loaded ok (v1.52) XML-LibXML-1.70/ XML-LibXML-1.70/lib/ XML-LibXML-1.70/lib/XML/ XML-LibXML-1.70/lib/XML/LibXML/ XML-LibXML-1.70/lib/XML/LibXML/DOM.pod XML-LibXML-1.70/lib/XML/LibXML/Reader.pm XML-LibXML-1.70/lib/XML/LibXML/InputCallback.pod XML-LibXML-1.70/lib/XML/LibXML/SAX/ XML-LibXML-1.70/lib/XML/LibXML/SAX/Builder.pod XML-LibXML-1.70/lib/XML/LibXML/SAX/Parser.pm XML-LibXML-1.70/lib/XML/LibXML/SAX/Builder.pm XML-LibXML-1.70/lib/XML/LibXML/SAX/Generator.pm XML-LibXML-1.70/lib/XML/LibXML/Common.pod XML-LibXML-1.70/lib/XML/LibXML/XPathExpression.pod XML-LibXML-1.70/lib/XML/LibXML/Parser.pod XML-LibXML-1.70/lib/XML/LibXML/Text.pod XML-LibXML-1.70/lib/XML/LibXML/RegExp.pod XML-LibXML-1.70/lib/XML/LibXML/ErrNo.pod XML-LibXML-1.70/lib/XML/LibXML/Document.pod XML-LibXML-1.70/lib/XML/LibXML/CDATASection.pod XML-LibXML-1.70/lib/XML/LibXML/Reader.pod XML-LibXML-1.70/lib/XML/LibXML/Comment.pod XML-LibXML-1.70/lib/XML/LibXML/Number.pm XML-LibXML-1.70/lib/XML/LibXML/Node.pod XML-LibXML-1.70/lib/XML/LibXML/SAX.pod XML-LibXML-1.70/lib/XML/LibXML/XPathContext.pm XML-LibXML-1.70/lib/XML/LibXML/Boolean.pm XML-LibXML-1.70/lib/XML/LibXML/Schema.pod XML-LibXML-1.70/lib/XML/LibXML/Namespace.pod XML-LibXML-1.70/lib/XML/LibXML/ErrNo.pm XML-LibXML-1.70/lib/XML/LibXML/PI.pod XML-LibXML-1.70/lib/XML/LibXML/Error.pod XML-LibXML-1.70/lib/XML/LibXML/Dtd.pod XML-LibXML-1.70/lib/XML/LibXML/Common.pm XML-LibXML-1.70/lib/XML/LibXML/Error.pm XML-LibXML-1.70/lib/XML/LibXML/NodeList.pm XML-LibXML-1.70/lib/XML/LibXML/DocumentFragment.pod XML-LibXML-1.70/lib/XML/LibXML/XPathContext.pod XML-LibXML-1.70/lib/XML/LibXML/Attr.pod XML-LibXML-1.70/lib/XML/LibXML/RelaxNG.pod XML-LibXML-1.70/lib/XML/LibXML/SAX.pm XML-LibXML-1.70/lib/XML/LibXML/Literal.pm XML-LibXML-1.70/lib/XML/LibXML/Element.pod XML-LibXML-1.70/lib/XML/LibXML/Pattern.pod XML-LibXML-1.70/Changes XML-LibXML-1.70/example/ XML-LibXML-1.70/example/test.html XML-LibXML-1.70/example/complex/ XML-LibXML-1.70/example/complex/dtd/ XML-LibXML-1.70/example/complex/dtd/g.dtd XML-LibXML-1.70/example/complex/dtd/f.dtd XML-LibXML-1.70/example/complex/complex2.xml XML-LibXML-1.70/example/complex/complex.xml XML-LibXML-1.70/example/complex/complex.dtd XML-LibXML-1.70/example/test.dtd XML-LibXML-1.70/example/article_internal_bad.xml XML-LibXML-1.70/example/dtd.xml XML-LibXML-1.70/example/utf-16-1.html XML-LibXML-1.70/example/enc2_latin2.html XML-LibXML-1.70/example/ns.xml XML-LibXML-1.70/example/article_external_bad.xml XML-LibXML-1.70/example/xmlns/ XML-LibXML-1.70/example/xmlns/badguy.xml XML-LibXML-1.70/example/xmlns/goodguy.xml XML-LibXML-1.70/example/article.xml XML-LibXML-1.70/example/xmllibxmldocs.pl XML-LibXML-1.70/example/test4.xml XML-LibXML-1.70/example/enc_latin2.html XML-LibXML-1.70/example/test3.xml XML-LibXML-1.70/example/ext_ent.dtd XML-LibXML-1.70/example/article_internal.xml XML-LibXML-1.70/example/catalog.xml XML-LibXML-1.70/example/xpath.pl XML-LibXML-1.70/example/utf-16-2.html XML-LibXML-1.70/example/cb_example.pl XML-LibXML-1.70/example/test.xhtml XML-LibXML-1.70/example/test.xml XML-LibXML-1.70/example/bad.dtd XML-LibXML-1.70/example/bad.xml XML-LibXML-1.70/example/article_bad.xml XML-LibXML-1.70/example/dromeds.xml XML-LibXML-1.70/example/test2.xml XML-LibXML-1.70/example/utf-16-2.xml XML-LibXML-1.70/test/ XML-LibXML-1.70/test/schema/ XML-LibXML-1.70/test/schema/demo.xml XML-LibXML-1.70/test/schema/badschema.xsd XML-LibXML-1.70/test/schema/schema.xsd XML-LibXML-1.70/test/schema/invaliddemo.xml XML-LibXML-1.70/test/relaxng/ XML-LibXML-1.70/test/relaxng/invaliddemo.xml XML-LibXML-1.70/test/relaxng/demo.rng XML-LibXML-1.70/test/relaxng/badschema.rng XML-LibXML-1.70/test/relaxng/demo.xml XML-LibXML-1.70/test/relaxng/schema.rng XML-LibXML-1.70/test/relaxng/demo3.rng XML-LibXML-1.70/test/relaxng/demo2.rng XML-LibXML-1.70/test/relaxng/demo4.rng XML-LibXML-1.70/test/xinclude/ XML-LibXML-1.70/test/xinclude/xinclude.xml XML-LibXML-1.70/test/xinclude/entity.txt XML-LibXML-1.70/test/xinclude/test.xml XML-LibXML-1.70/test/textReader/ XML-LibXML-1.70/test/textReader/countries.xml XML-LibXML-1.70/debian/ XML-LibXML-1.70/debian/rules XML-LibXML-1.70/debian/copyright XML-LibXML-1.70/debian/libxml-libxml-perl.postinst XML-LibXML-1.70/debian/control XML-LibXML-1.70/debian/libxml-libxml-perl.install XML-LibXML-1.70/debian/changelog XML-LibXML-1.70/debian/libxml-libxml-perl.examples XML-LibXML-1.70/debian/libxml-libxml-perl.docs XML-LibXML-1.70/debian/libxml-libxml-perl.prerm XML-LibXML-1.70/debian/compat XML-LibXML-1.70/t/ XML-LibXML-1.70/t/25relaxng.t XML-LibXML-1.70/t/40reader.t XML-LibXML-1.70/t/32xpc_variables.t XML-LibXML-1.70/t/10ns.t XML-LibXML-1.70/t/14sax.t XML-LibXML-1.70/t/06elements.t XML-LibXML-1.70/t/20extras.t XML-LibXML-1.70/t/04node.t XML-LibXML-1.70/t/03doc.t XML-LibXML-1.70/t/18docfree.t XML-LibXML-1.70/t/07dtd.t XML-LibXML-1.70/t/45regex.t XML-LibXML-1.70/t/24c14n.t XML-LibXML-1.70/t/23rawfunctions.t XML-LibXML-1.70/t/12html.t XML-LibXML-1.70/t/19encoding.t XML-LibXML-1.70/t/11memory.t XML-LibXML-1.70/t/43options.t XML-LibXML-1.70/t/27new_callbacks_simple.t XML-LibXML-1.70/t/01basic.t XML-LibXML-1.70/t/80registryleak.t XML-LibXML-1.70/t/17callbacks.t XML-LibXML-1.70/t/26schema.t XML-LibXML-1.70/t/61error.t XML-LibXML-1.70/t/44extent.t XML-LibXML-1.70/t/13dtd.t XML-LibXML-1.70/t/21catalog.t XML-LibXML-1.70/t/30xpathcontext.t XML-LibXML-1.70/t/16docnodes.t XML-LibXML-1.70/t/08findnodes.t XML-LibXML-1.70/t/42common.t XML-LibXML-1.70/t/31xpc_functions.t XML-LibXML-1.70/t/60struct_error.t XML-LibXML-1.70/t/41xinclude.t XML-LibXML-1.70/t/02parse.t XML-LibXML-1.70/t/05text.t XML-LibXML-1.70/t/15nodelist.t XML-LibXML-1.70/t/28new_callbacks_multiple.t XML-LibXML-1.70/t/90threads.t XML-LibXML-1.70/t/09xpath.t XML-LibXML-1.70/t/29id.t XML-LibXML-1.70/xpath.c XML-LibXML-1.70/ppport.h XML-LibXML-1.70/xpath.h XML-LibXML-1.70/README XML-LibXML-1.70/perl-libxml-sax.c XML-LibXML-1.70/dom.c XML-LibXML-1.70/LibXML.pod XML-LibXML-1.70/LibXML.pm XML-LibXML-1.70/perl-libxml-sax.h XML-LibXML-1.70/Makefile.PL XML-LibXML-1.70/perl-libxml-mm.h XML-LibXML-1.70/Av_CharPtrPtr.h XML-LibXML-1.70/MANIFEST XML-LibXML-1.70/TODO XML-LibXML-1.70/typemap XML-LibXML-1.70/xpathcontext.h XML-LibXML-1.70/Av_CharPtrPtr.c XML-LibXML-1.70/dom.h XML-LibXML-1.70/docs/ XML-LibXML-1.70/docs/libxml.dbk XML-LibXML-1.70/LICENSE XML-LibXML-1.70/perl-libxml-mm.c XML-LibXML-1.70/LibXML.xs XML-LibXML-1.70/META.yml CPAN: File::Temp loaded ok (v0.22) Working directory is /Users/me/.cpan/build/XML-LibXML-1.70-G6_WV2 my-computer:~/.cpan/build/XML-LibXML-1.70-G6_WV2 root#

      I got a complicated prompt ending in 'root#' instead of a 'shell>' prompt. At the 'root#' prompt, I typed in your commands, and now both XML::LibXML and XML::Simple work again. After I was done, I typed 'exit' got me out of the 'root#' prompt and back to the cpan prompt, and typing 'q' exits the cpan prompt.

      Thanks.