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

I have reinstalled strawberry-perl-5.20.2.1-64bit and using PAR:Packer 1.025

My program uses XML::Simple and XML::LibXML is not installed, and the program run OK as a perl script.

After packing and moving to a system without perl the program fails that is cannot find XML::LibXML::SAX, it seems PAR::Packer adds this in as a requirement.

Is there a way I can get PAR::Packer not to think it needs XML::LibXML?

The complete error is below, this occurs when the program tries to run XML::Simple commands

Can't locate XML/LibXML/SAX.pm in @INC (you may need to install the XML::LibXML::SAX module) (@INC contains: C:\Users\Hulley\AppData\Local\Temp\par-48756c6c6579\cache-356fb063bf66ffda26ffc1023419622e2d0e5508\inc\lib C:\Users\Hulley\AppData\Local\Temp\par-48756c6c6579\cache-356fb063bf66ffda26ffc1023419622e2d0e5508\inc CODE(0x2f5c120) CODE(0x2f5a750)) at (eval 44) line 1.


Hope you can help

Thanks
Rob

  • Comment on After compiling a script using PAR::Packer I get the error Can't locate XML/LibXML/SAX.pm in @INC

Replies are listed 'Best First'.
Re: After compiling a script using PAR::Packer I get the error Can't locate XML/LibXML/SAX.pm in @INC
by ikegami (Patriarch) on May 15, 2015 at 18:13 UTC

    First of all, XML::LibXML (and thus XML::LibXML::SAX) come with Strawberry Perl. So you do have the module.

    In your Perl installation, there's a file named XML/SAX/ParserDetails.ini that says which SAX parsers you have installed. XML::Simple uses the first parser listed in this file. For you, that parser is XML::LibXML:SAX.

    The problem is that PAR::Packer doesn't know this, so it didn't include XML::LibXML:SAX in the distributable package. You'll need to notify PAR::Packer of this when you create the distributable package.

    pp -M XML::LibXML::SAX ...

    Updated due to a better understanding of the question.

        I've never used pp. Feel free to provide the more complete command.
Re: After compiling a script using PAR::Packer I get the error Can't locate XML/LibXML/SAX.pm in @INC
by Anonymous Monk on May 14, 2015 at 23:03 UTC
Re: After compiling a script using PAR::Packer I get the error Can't locate XML/LibXML/SAX.pm in @INC
by Anonymous Monk on May 14, 2015 at 23:38 UTC
    So
    BEGIN { $ENV{XML_SIMPLE_PREFERRED_PARSER}='XML::Parser'; } use XML::Simple qw/ XMLin /;
    works with pp -c foo.pl to depend on XML::Parser and not libxml...
      $XML::Simple::PREFERRED_PARSER = 'XML::Parser';
      would be more straightforward and less error-prone than
      $ENV{XML_SIMPLE_PREFERRED_PARSER} = 'XML::Parser';

      Whichever method you use, it doesn't need to be done before the module is loaded; just before XMLin is called. Safer:

      use XML::Simple qw( XMLin ); sub parse_xml { local $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; return XMLin(@_); } my $xml = parse_xml(...);

        would be more straightforward and less error-prone than

        Nonsense

        Whichever method you use, it doesn't need to be done before the module is loaded; just before XMLin is called.

        true

        Safer:

        Nonsense

Re: After compiling a script using PAR::Packer I get the error Can't locate XML/LibXML/SAX.pm in @INC
by Anonymous Monk on May 14, 2015 at 22:59 UTC

    After packing and moving to a system without perl the program fails that is cannot find XML::LibXML::SAX, it seems PAR::Packer adds this in as a requirement.

    After doing what?