输出包含所有模块的Perl可执行文件,以及指定版本的Perl
我有一个脚本开头是这样的:
use strict;
use feature 'say';
use warnings FATAL => 'all';
use autodie ':default';
use Term::ANSIColor;
use Cwd 'getcwd';
use SimpleFlow qw(task say2);
use Getopt::ArgParse;
use File::Basename;
use POSIX 'strftime';
use File::Temp 'tempfile';
use Scalar::Util qw(looks_like_number);
use List::Util qw(min max sum);
在Perl 5.42下运行正常。
我打算在Linux上创建一个独立的可执行文件,这样就能把Perl的版本以及所有相关模块都打包在一起,这样就不需要额外的安装。
我一直在使用PAR::Packer,它是 pp,但它不起作用:
pp -I /home/con/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/ -o x.pepPriML x.pepPriML.pl
它输出为:
Built-in function 'builtin::blessed' is experimental at /home/con/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/overload.pm line 103.
Perl v5.40.0 required--this is only v5.38.2, stopped at /home/con/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/builtin.pm line 3.
BEGIN failed--compilation aborted at /home/con/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/builtin.pm line 3.
Compilation failed in require at /home/con/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/File/Copy.pm line 14.
BEGIN failed--compilation aborted at /home/con/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/File/Copy.pm line 14.
Compilation failed in require at /usr/share/perl5/Archive/Zip/Archive.pm line 9.
BEGIN failed--compilation aborted at /usr/share/perl5/Archive/Zip/Archive.pm line 9.
Compilation failed in require at /usr/share/perl5/Archive/Zip.pm line 316.
Compilation failed in require at -e line 236.
Failed to execute temporary parl (class PAR::StrippedPARL::Static) '/tmp/parl1X6c': $?=65280 at /usr/share/perl5/PAR/StrippedPARL/Base.pm line 77, <DATA> line 1.
/usr/bin/pp: Failed to extract a parl from 'PAR::StrippedPARL::Static' to file '/tmp/parlHjpr_2o' at /usr/share/perl5/PAR/Packer.pm line 1216, <DATA> line 1.
即使在脚本中指定了perl 5.0382,它也无法与 pp 一起编译。
如何创建一个独立的可执行文件,使所有库都随Perl版本一起打包?
解决方案
它嵌入了5.38,因此可能意味着你正在使用一个由5.38构建安装的 pp。请使用一个由你的5.42构建安装的版本。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。