我正在尝试从完成的perl脚本制作可执行程序。我毫不费力地安装了PAR :: Packer模块。但是,我不认为我做得正确。下面是我要编译的脚本中的代码:
use PAR::Packer qw(pp);
my %pp;
% pp -o prlgap.exe prlgap.pl;
以上是我在 Perl Monk 上找到的示例。如果我运行脚本并且出现以下错误:
Unquoted string "prlgap" may clash with future reserved word at
C:\Strawberry\prlgap.pl line 15. Syntax error at
C:\Strawberry\prlgap.pl line 15 near "% pp -o "
代码的第三行是第15行。尝试通过运行程序来编译程序似乎很奇怪。根据我的经验,这始终是在外部完成的。我想念什么?
答案 0 :(得分:0)
经过一些网页搜索,我发现这是在外部完成的。只需在命令提示符下xxx <- "
#' # Title
Hello world
#+ one_plus_one
1 + 1
"
tmp <- tempfile()
sink(tmp)
cat("
---
title: 'Sample Document'
output:
html_document:
toc: true
theme: united
pdf_document:
toc: true
highlight: zenburn
---", xxx)
sink()
w.d <- getwd()
rmarkdown::render(tmp, output_file=paste(w.d, "myfile", sep="/"))
。注意,如果您遇到快速循环的操作,确实会踩刹车。同样,生成的可执行文件确实很大。在我删除了不需要的任何模块之后,我的65行脚本被编译成一个8兆字节的程序。 Strawberry安装程序添加了环境变量,这使得可以从驱动器上的任何位置运行脚本。它仅需要将pp program.pl
扩展名添加到名称中。例如.pl
。
感谢大家的回复...