问题描述
我一直在使用PAR :: Packer从Perl脚本中创建独立的可执行文件.我唯一遇到的困难是弄清楚我必须通过 -l 选项强制它包括哪些额外的DLL.
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.
我现在正在使用需要使用utf16-le进行编码的Perl脚本. Encode :: find_encoding
函数在脚本中可以正常工作,但是在我将其与 pp
打包后无法正常工作.
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
.
这里有一个小脚本(我们称它为encode.pl)来说明问题:
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;
如果运行此命令,它将打印类似 Encode :: Unicode = HASH(xxxxxx)
的内容.但是,用 pp
打包它,它将不再起作用:
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
现在,当我运行encode_test.exe时,我得到了:
Now when I run encode_test.exe, I get this:
Use of uninitialized value $_UTF16 in print at script/encode_test.pl line 5.
即使使用 pp
打包后,任何人都可以告诉我我需要做些什么(例如要包括哪些库或任何其他解决方案)以使这项工作正确进行?
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
?
推荐答案
使用 -x
选项运行 pp
当然可以,但是我不接受使用它这种情况是因为它运行程序,并且因为这是一个GUI应用程序,所以该命令将不再是自动化的.
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.
罪魁祸首是Encode.pm的第120行用于加载Encode :: Unicode的运行时要求.为了使该程序正常工作,我使用了以下内容:
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
请注意,使用反斜杠(Windows方式)会导致 pp
命令失败,因此必须将其替换为正斜杠.
Note that using backslashes (the Windows way) causes a failure in the pp
command, so those had to be replaced with forward slashes.
这篇关于将编码与PAR Packer一起使用时要包括的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!