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

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...
  • Comment on Re: After compiling a script using PAR::Packer I get the error Can't locate XML/LibXML/SAX.pm in @INC
  • Download Code

Replies are listed 'Best First'.
Re^2: 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:14 UTC
    $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

        If you think it doesn't matter which parser is used, you've been lucky or you haven't used XML::Simple much. You don't have to be an asshole about it.