PAR打包器不包括用户定义的模块

时间:2016-03-01 12:34:17

标签: perl-module par pp-perl-par-packager

我有一个Perl脚本test.pl,其中包含另一个Perl模块fact.pm,它位于crypt / Module目录下。 crypt / test.pl的源代码是:

#!/usr/bin/perl
use Term::ANSIColor qw(:constants);
use File::Path;
use POSIX qw(strftime);
use File::Basename qw(dirname);
use Cwd  qw(abs_path);
use lib dirname(dirname abs_path $0);
use crypt::Module::fact qw(factorial);

&factorial();#function present in fact.pm
print("Thanks for that thought \n");

给出的PAR包装器命令是

pp -M Module::fact -o test test.pl

只是在不同的目录路径上复制可执行测试并执行它我收到以下错误:

Can't locate crypt/Module/fact.pm in @INC (you may need to install the crypt::Module::fact module)

如何将模块包含在可执行文件中?

1 个答案:

答案 0 :(得分:0)

首先,我建议对pp实用程序使用-c和/或-x选项,这些实用程序用于确定附加的运行时依赖性"。我已养成使用两者的习惯。

虽然您使用-M选项添加模块,但我认为您有使用该选项的拼写错误。在您的代码中,您正在使用" crypt :: Module :: fact"模块,但您指定的是" Module :: fact"带有-M选项的模块。也许如果你使用" -M crypt :: Module :: fact"而不是" -M Module :: fact",您的问题可能会得到解决。

此外,您可能需要使用-I(或-lib)来指定任何其他模块库目录的路径。

相关问题