您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

pp(PAR)在哪里解压缩添加(-a)文件?

pp(PAR)在哪里解压缩添加(-a)文件?

打包的可执行文件中的文件提取一个临时目录(通常是/ tmp / par-USERNAME / cache- XXXXXXX)。要访问这些文件,请执行以下操作:

#!/usr/bin/perl

# Reads a data file from the archive (added with -a)
print PAR::read_file("data");

# Will execute "script2" in the archive and exit. Will not return to this script.
require PAR;
PAR->import( { file => $0, run => 'script2' } );

您还可以建立与可执行文件具有相同名称的可执行文件的符号链接,然后运行它们。

实际上,重读您的问题,仅访问PAR_TEMP环境变量可能更有用:

#!/usr/bin/perl
use File::Slurp qw(slurp);

$data_dir = "$ENV{PAR_TEMP}/inc";
$script_dir = "$data_dir/script";

print slurp("$data_dir/datafile");

# file access permissions are not preserved as far as I can tell,
# so you'll have to invoke the interpreter explicitly.
system 'perl', "$script_dir/script2", @args;
其他 2022/1/1 18:20:28 有576人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶