如何使用Perl将Perl脚本编译成Windows可执行文件?
在Windows下用草莓Perl将简单的Perl脚本编译成可执行文件的最简单方法是什么(据我所知,这是可能的,也是免费的)如何使用Perl将Perl脚本编译成Windows可执行文件?,perl,strawberry-perl,perl2exe,Perl,Strawberry Perl,Perl2exe,在Windows下用草莓Perl将简单的Perl脚本编译成可执行文件的最简单方法是什么(据我所知,这是可能的,也是免费的) 在过去,我使用过ActiveState编译器和perl2exe,非常简单。但是,现在经过几次计算机更改和操作系统更新后,我丢失了许可证,我想找到一个更好的/永久的解决方案。安装并使用pp实用程序。有三个打包程序和两个编译器: 免费包装商:PAR 商业包装商:perl2exe、perlapp 编译器:B::C,B::CC (注意:perlfaq3仍然是错误的) 对于草莓,您
在过去,我使用过ActiveState编译器和perl2exe,非常简单。但是,现在经过几次计算机更改和操作系统更新后,我丢失了许可证,我想找到一个更好的/永久的解决方案。安装并使用pp实用程序。有三个打包程序和两个编译器: 免费包装商:PAR
商业包装商:perl2exe、perlapp
编译器:B::C,B::CC (注意:perlfaq3仍然是错误的) 对于草莓,您需要git master(1.43)提供的perl-5.16和B-C,因为B-C-1.42不支持5.16。
::简短回答:
:: short answer :
:: perl -MCPAN -e "install PAR::Packer"
pp -o <<DesiredExeName>>.exe <<MyFancyPerlScript>>
:: long answer - create the following cmd , adjust vars to your taste ...
:: next_line_is_templatized
:: file:compile-morphus.1.2.3.dev.ysg.cmd v1.0.0
:: disable the echo
@echo off
:: this is part of the name of the file - not used
set _Action=run
:: the name of the Product next_line_is_templatized
set _ProductName=morphus
:: the version of the current Product next_line_is_templatized
set _ProductVersion=1.2.3
:: could be dev , test , dev , prod next_line_is_templatized
set _ProductType=dev
:: who owns this Product / environment next_line_is_templatized
set _ProductOwner=ysg
:: identifies an instance of the tool ( new instance for this version could be created by simply changing the owner )
set _EnvironmentName=%_ProductName%.%_ProductVersion%.%_ProductType%.%_ProductOwner%
:: go the run dir
cd %~dp0
:: do 4 times going up
for /L %%i in (1,1,5) do pushd ..
:: The BaseDir is 4 dirs up than the run dir
set _ProductBaseDir=%CD%
:: debug echo BEFORE _ProductBaseDir is %_ProductBaseDir%
:: remove the trailing \
IF %_ProductBaseDir:~-1%==\ SET _ProductBaseDir=%_ProductBaseDir:~0,-1%
:: debug echo AFTER _ProductBaseDir is %_ProductBaseDir%
:: debug pause
:: The version directory of the Product
set _ProductVersionDir=%_ProductBaseDir%\%_ProductName%\%_EnvironmentName%
:: the dir under which all the perl scripts are placed
set _ProductVersionPerlDir=%_ProductVersionDir%\sfw\perl
:: The Perl script performing all the tasks
set _PerlScript=%_ProductVersionPerlDir%\%_Action%_%_ProductName%.pl
:: where the log events are stored
set _RunLog=%_ProductVersionDir%\data\log\compile-%_ProductName%.cmd.log
:: define a favorite editor
set _MyEditor=textpad
ECHO Check the variables
set _
:: debug PAUSE
:: truncate the run log
echo date is %date% time is %time% > %_RunLog%
:: uncomment this to debug all the vars
:: debug set >> %_RunLog%
:: for each perl pm and or pl file to check syntax and with output to logs
for /f %%i in ('dir %_ProductVersionPerlDir%\*.pl /s /b /a-d' ) do echo %%i >> %_RunLog%&perl -wc %%i | tee -a %_RunLog% 2>&1
:: for each perl pm and or pl file to check syntax and with output to logs
for /f %%i in ('dir %_ProductVersionPerlDir%\*.pm /s /b /a-d' ) do echo %%i >> %_RunLog%&perl -wc %%i | tee -a %_RunLog% 2>&1
:: now open the run log
cmd /c start /max %_MyEditor% %_RunLog%
:: this is the call without debugging
:: old
echo CFPoint1 OK The run cmd script %0 is executed >> %_RunLog%
echo CFPoint2 OK compile the exe file STDOUT and STDERR to a single _RunLog file >> %_RunLog%
cd %_ProductVersionPerlDir%
pp -o %_Action%_%_ProductName%.exe %_PerlScript% | tee -a %_RunLog% 2>&1
:: open the run log
cmd /c start /max %_MyEditor% %_RunLog%
:: uncomment this line to wait for 5 seconds
:: ping localhost -n 5
:: uncomment this line to see what is happening
:: PAUSE
::
:::::::
:: Purpose:
:: To compile every *.pl file into *.exe file under a folder
:::::::
:: Requirements :
:: perl , pp , win gnu utils tee
:: perl -MCPAN -e "install PAR::Packer"
:: text editor supporting <<textEditor>> <<FileNameToOpen>> cmd call syntax
:::::::
:: VersionHistory
:: 1.0.0 --- 2012-06-23 12:05:45 --- ysg --- Initial creation from run_morphus.cmd
:::::::
:: eof file:compile-morphus.1.2.3.dev.ysg.cmd v1.0.0
::perl-MCPAN-e“安装PAR::Packer”
pp-o.exe
::长答案-创建以下命令,根据您的喜好调整变量。。。
::下一行是模板化的
::文件:compile-morphus.1.2.3.dev.ysg.cmd v1.0.0
::禁用回音
@回音
::这是文件名的一部分-未使用
设置_Action=run
::下一行的产品名称已模板化
设置“\u ProductName=morphus”
::下一行当前产品的版本已模板化
设置_ProductVersion=1.2.3
::可能是开发、测试、开发、产品下一行已模板化
设置_ProductType=dev
::谁拥有此产品/环境下一条线已模板化
集合_ProductOwner=ysg
::标识工具的实例(只需更改所有者即可创建此版本的新实例)
设置“\u环境名称=%\u产品名称%.%\u产品版本%.%\u产品类型%.%\u产品所有者%
::去跑步
cd%~dp0
::往上爬4次
对于(1,1,5)中的/L%%i,请按。。
::BaseDir比run dir高4 dir
设置_ProductBaseDir=%CD%
::调试回显在\u ProductBaseDir为%\u ProductBaseDir%之前
::移除尾随\
如果%\u ProductBaseDir:~-1%=\SET\u ProductBaseDir=%\u ProductBaseDir:~0,-1%
::调试回显在_ProductBaseDir为%\u ProductBaseDir%之后
::调试暂停
::产品的版本目录
set\u ProductVersionDir=%\u ProductBaseDir%\%\u产品名称%\%\u环境名称%
::放置所有perl脚本的目录
set\u ProductVersionPerlDir=%\u ProductVersionDir%\sfw\perl
::执行所有任务的Perl脚本
设置\\ uPERLScript=%\ uProductVersionPerldir%\%\ uAction%\\ uProductName%.pl
::存储日志事件的位置
设置\u RunLog=%\u ProductVersionDir%\data\log\compile-%\u ProductName%.cmd.log
::定义收藏夹编辑器
设置_MyEditor=textpad
回显检查变量
设置_
::调试暂停
::截断运行日志
回显日期为%date%时间为%time%>%\u运行日志%
::取消对此的注释以调试所有变量
::调试集>>%\u运行日志%
::对于每个perl pm和/或pl文件,检查语法并将输出输出到日志
对于/f%%i in('dir%\u ProductVersionPerlDir%\*.pl/s/b/a-d'),执行echo%%i>%\u RunLog%&perl-wc%%i | tee-a%\u RunLog%2>&1
::对于每个perl pm和/或pl文件,检查语法并将输出输出到日志
对于/f%%i in('dir%\u ProductVersionPerlDir%\*.pm/s/b/a-d'),执行echo%%i>%\u RunLog%&perl-wc%%i | tee-a%\u RunLog%2>&1
::现在打开运行日志
cmd/c start/max%\u MyEditor%\u RunLog%
::这是未经调试的调用
::老
echo CFPoint1 OK运行指令脚本%0已执行>>%\u运行日志%
echo CFPoint2 OK将exe文件STDOUT和STDERR编译为单个运行日志文件>>%\u运行日志%
cd%\U产品版本Perldir%
pp-o%\u操作%\u%\u产品名%.exe%\u PerlScript%\124; tee-a%\u运行日志%2>&1
::打开运行日志
cmd/c start/max%\u MyEditor%\u RunLog%
::取消对此行的注释以等待5秒
::ping localhost-n 5
::取消对此行的注释以查看发生了什么
::暂停
::
:::::::
::目的:
::将每个*.pl文件编译为文件夹下的*.exe文件
:::::::
::要求:
::perl,pp,win gnu utils tee
::perl-MCPAN-e“安装PAR::Packer”
::支持cmd调用语法的文本编辑器
:::::::
::版本历史
::1.0.0---2012-06-23 12:05:45---ysg---run_morphus.cmd的初始创建
:::::::
::eof文件:compile-morphus.1.2.3.dev.ysg.cmd v1.0.0
下面的说明:PAR::PACKE/PP附带一个手册:为了对PAR所能做的有一个相当深入的概述,请看一下我的YAPC::EU 2008,这对我来说似乎不起作用。