in reply to encoding failure with XML::Twig

OHHHH! I completely missed the fact that you're using a packager. I thought pp was referring to "pretty print" (which is what your code does). What can I say? I use xml_pp quite often.

@XML::Parser::Expat::Encoding_Path is built from @INC. I bet that the problem is that your packager puts a callback function in @INC instead of the path to the files.

Assuming pp actually extracts the files to some directory, you can do:

BEGIN { my $path_to_enc_files = ...; $path_to_enc_files =~ s{/XML/Parser/Encodings/?\z}{}; local @INC = ( @INC, $path_to_enc_files ); require XML::Parser::Expat; }

According to almut's post, that boils down to

BEGIN { local @INC = ( @INC, $ENV{PAR_TEMP} ); require XML::Parser::Expat; }

Place this before the first use XML::Parser::Expat;

Replies are listed 'Best First'.
Re^2: encoding failure with XML::Twig
by chastevens (Initiate) on Nov 19, 2009 at 20:24 UTC

    Thank you both, you're saints. I'll try to explain better in future posts, that was a bit confusing.

    That solved the issue in my example, but I'm still having the problem in my main script. Should that go before all use statments, or just directly before use XML::Twig?

    Apparently Expat has 4 embedded encoding formats and if it's not one of those 4 it looks at the Encodings directory. windows-1252 isn't one of the 4 embedded. Parser doesn't include this directory by default.

      Should that go before all use statments, or just directly before use XML::Twig?

      As early as you want. It was to be before any direct or indirect call to use XML::Parser::Expat;, so the earlier the safer.

      I tried installing pp to do some debugging, but it's crashing. Sorry, I can't help you more than this.