What to include when using Encode with PAR Packer

有些话、适合烂在心里 提交于 2021-02-10 13:56:30

问题


I've been working with PAR::Packer to create standalone executable files out of Perl scripts. The only difficulty I have with it is figuring out what extra DLLs I have to force it to include via the -l option.

I'm now working with a Perl script that requires Encoding with utf16-le. The Encode::find_encoding function works just fine in the script, but it doesn't work after I have packaged it with pp.

Here's a tiny script (let's call it encode.pl) to illustrate the problem:

use strict;
use warnings;
use Encode;
my $_UTF16 = Encode::find_encoding ('utf16-le');
print $_UTF16;

If you run this, it will print something like Encode::Unicode=HASH(xxxxxx). Pack it up with pp, however, and it no longer works:

pp -o encode_test.exe encode_test.pl

Now when I run encode_test.exe, I get this:

Use of uninitialized value $_UTF16 in print at script/encode_test.pl line 5.

Can anyone tell me what I need to do (e.g. what libraries to include or any other solution) to make this work right even after packaging with pp?


回答1:


Running pp with the -x option works, of course, but using it was unacceptable in my case because this runs the program, and since this is a GUI application this command would no longer be automatable.

The culprit was a run-time require used by Encode.pm, line 120, to load Encode::Unicode. To make this program work, I used the following:

pp -o encode_test.exe encode_test.pl -M C:/strawberry/perl/lib/Encode/Unicode.pm

Note that using backslashes (the Windows way) causes a failure in the pp command, so those had to be replaced with forward slashes.



来源:https://stackoverflow.com/questions/18522945/what-to-include-when-using-encode-with-par-packer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!