1
votes

I have some perl code that runs great on my Mac. I moved it to a client linux box and I'm getting an error when trying to use XML::Simple:

#! usr/local/bin/perl5
#use strict;
#use warnings;
use XML::Simple;

# open xml file
my $product = XMLin('xml/ASSET_ALLOCATION_QFR.XML');

This is the least bit of code the shows the error:

"Can't locate object method "new" via package "XML::LibXML::SAX"

... the goes on to list the a diferent path from what I spec'd in the #! line. It looks like "usr/opt/perl5..."

What is different that it works on my Mac but not on Linux, and how do I fix it? Why does it mention the LibXML package when I'm using Simple?

Thanks

1
XML::Simple is not a parser. It relies on other modules to do the actual parsing. Something appears to be messed up with your installed modules. What do you get if you do /usr/local/bin/perl5 -e'use XML::LibXML::SAX; print "ok\n"'? - ikegami
Thanks ikegami. The test you suggested prints OK. I found out what the issue was. I was running the script like this: "pert test.pl" which was bypassing the special install referenced after the shebang. When I ran it as "perl5 test.pl" it works perfect. Thanks! - dbonneville

1 Answers

2
votes

Your shebang is wrong, you should have a slash at the beginning:

#!/usr/local/bin/perl5

And you'll need to install XML::LibXML::SAX, it sounds like. Use this:

cpan XML::LibXML::SAX