如何编译我的Perl脚本,以便可以在没有安装perl的系统上执行?

时间:2021-04-22 07:16:02

I have a .pl file and I want to execute that file in any system even though perl is not installed. How can i achieve it?

我有一个.pl文件,我想在任何系统中执行该文件,即使没有安装perl。我怎样才能实现它?

Can any one let me know with some good examples to do that?

任何人都可以通过一些很好的例子让我知道吗?

9 个解决方案

#1


41  

pp can create an executable that includes perl and your script (and any module dependencies), but it will be specific to your architecture, so you couldn't run it on both Windows and linux for instance.

pp可以创建包含perl和脚本(以及任何模块依赖项)的可执行文件,但它将特定于您的体系结构,因此您无法在Windows和Linux上运行它。

From its doc:

从它的文档:

To make a stand-alone executable, suitable for running on a machine that doesn't have perl installed:

要创建独立的可执行文件,适合在未安装perl的计算机上运行:

   % pp -o packed.exe source.pl        # makes packed.exe
   # Now, deploy 'packed.exe' to target machine...
   $ packed.exe                        # run it

(% and $ there are command prompts on different machines).

(%和$在不同的机器上有命令提示)。

#2


26  

  1. Install PAR::Packer. Example for *nix:

    安装PAR :: Packer。 * nix示例:

    sudo cpan -i PAR::Packer

    For Strawberry Perl for Windows or for ActivePerl and MSVC installed:

    适用于Windows的Strawberry Perl或安装的ActivePerl和MSVC:

    cpan -i PAR::Packer
  2. Pack it with pp. It will create an executable named "example" or "example.exe" on Windows.

    用pp打包它。它将在Windows上创建一个名为“example”或“example.exe”的可执行文件。

    pp -o example example.pl

This would work only on the OS where it was built.

这只适用于构建它的操作系统。

P.S. It is really hard to find a Unix clone without Perl. Did you mean Windows?

附:没有Perl很难找到Unix克隆。你的意思是Windows?

#3


7  

Look at PAR (Perl Archiving Toolkit).

看看PAR(Perl Archiving Toolkit)。

PAR is a Cross-Platform Packaging and Deployment tool, dubbed as a cross between Java's JAR and Perl2EXE/PerlApp.

PAR是一个跨平台打包和部署工具,被称为Java的JAR和Perl2EXE / PerlApp之间的交叉。

#4


7  

From perlfaq3's answer to How can I compile my Perl program into byte code or C?:

从perlfaq3的回答我怎样才能将我的Perl程序编译成字节码或C?:


(contributed by brian d foy)

(由brian d foy提供)

In general, you can't do this. There are some things that may work for your situation though. People usually ask this question because they want to distribute their works without giving away the source code, and most solutions trade disk space for convenience. You probably won't see much of a speed increase either, since most solutions simply bundle a Perl interpreter in the final product (but see How can I make my Perl program run faster?).

一般来说,你不能这样做。有些事情可能对你的情况有用。人们通常会问这个问题,因为他们希望在不泄露源代码的情况下分发他们的作品,并且大多数解决方案为了方便而交换磁盘空间您可能也不会看到太多的速度增加,因为大多数解决方案只是在最终产品中捆绑Perl解释器(但是请参阅如何使我的Perl程序运行得更快?)。

The Perl Archive Toolkit ( http://par.perl.org/ ) is Perl's analog to Java's JAR. It's freely available and on CPAN ( http://search.cpan.org/dist/PAR/ ).

Perl Archive Toolkit(http://par.perl.org/)是Perl与Java JAR的类比。它可以在CPAN上免费获得(http://search.cpan.org/dist/PAR/)。

There are also some commercial products that may work for you, although you have to buy a license for them.

虽然您必须为他们购买许可证,但也有一些商业产品可能适合您。

The Perl Dev Kit ( http://www.activestate.com/Products/Perl_Dev_Kit/ ) from ActiveState can "Turn your Perl programs into ready-to-run executables for HP-UX, Linux, Solaris and Windows."

ActiveState的Perl Dev Kit(http://www.activestate.com/Products/Perl_Dev_Kit/)可以“将您的Perl程序转换为HP-UX,Linux,Solaris和Windows的可立即运行的可执行文件”。

Perl2Exe ( http://www.indigostar.com/perl2exe.htm ) is a command line program for converting perl scripts to executable files. It targets both Windows and unix platforms.

Perl2Exe(http://www.indigostar.com/perl2exe.htm)是一个命令行程序,用于将perl脚本转换为可执行文件。它针对Windows和unix平台。

#5


6  

And let's not forget ActiveState's PDK. It will allow you to compile UI, command line, Windows services and installers.

让我们不要忘记ActiveState的PDK。它将允许您编译UI,命令行,Windows服务和安装程序。

I highly recommend it, it has served me very well over the years, but it is around 300$ for a licence.

我强烈推荐它,多年来它一直很好用,但许可证大约300美元。

#6


5  

Note to Sinan and brian: perlfaq3 is still wrong.

思南和布莱恩注意:perlfaq3仍然是错误的。

See http://search.cpan.org/dist/B-C/perlcompile.pod

请参阅http://search.cpan.org/dist/B-C/perlcompile.pod

#7


3  

Cava Packager is great on the Windows ecosystem.

Cava Packager在Windows生态系统中非常出色。

#8


1  

Perl files are scripts, not executable programs. Therefore, for them to 'run', they are going to need an interpreter.

Perl文件是脚本,而不是可执行程序。因此,为了让他们“奔跑”,他们将需要一名翻译。

So, you have two choices: 1) Have the interpreter on the machine that you wish to run the script, or 2) Have the script running on a networked (or Internet) machine that you remotely connect to (ie with a browser)

因此,您有两种选择:1)在计算机上安装您希望运行脚本的解释器,或者2)让脚本在远程连接的网络(或Internet)计算机上运行(即使用浏览器)

#9


0  

On MaxOSX there may be perlcc. Type man perlcc. On my system (10.6.8) it's in /usr/bin. YMMV

在MaxOSX上可能有perlcc。输入man perlcc。在我的系统(10.6.8)上,它位于/ usr / bin中。因人而异

See http://search.cpan.org/~nwclark/perl-5.8.9/utils/perlcc.PL

请参阅http://search.cpan.org/~nwclark/perl-5.8.9/utils/perlcc.PL

#1


41  

pp can create an executable that includes perl and your script (and any module dependencies), but it will be specific to your architecture, so you couldn't run it on both Windows and linux for instance.

pp可以创建包含perl和脚本(以及任何模块依赖项)的可执行文件,但它将特定于您的体系结构,因此您无法在Windows和Linux上运行它。

From its doc:

从它的文档:

To make a stand-alone executable, suitable for running on a machine that doesn't have perl installed:

要创建独立的可执行文件,适合在未安装perl的计算机上运行:

   % pp -o packed.exe source.pl        # makes packed.exe
   # Now, deploy 'packed.exe' to target machine...
   $ packed.exe                        # run it

(% and $ there are command prompts on different machines).

(%和$在不同的机器上有命令提示)。

#2


26  

  1. Install PAR::Packer. Example for *nix:

    安装PAR :: Packer。 * nix示例:

    sudo cpan -i PAR::Packer

    For Strawberry Perl for Windows or for ActivePerl and MSVC installed:

    适用于Windows的Strawberry Perl或安装的ActivePerl和MSVC:

    cpan -i PAR::Packer
  2. Pack it with pp. It will create an executable named "example" or "example.exe" on Windows.

    用pp打包它。它将在Windows上创建一个名为“example”或“example.exe”的可执行文件。

    pp -o example example.pl

This would work only on the OS where it was built.

这只适用于构建它的操作系统。

P.S. It is really hard to find a Unix clone without Perl. Did you mean Windows?

附:没有Perl很难找到Unix克隆。你的意思是Windows?

#3


7  

Look at PAR (Perl Archiving Toolkit).

看看PAR(Perl Archiving Toolkit)。

PAR is a Cross-Platform Packaging and Deployment tool, dubbed as a cross between Java's JAR and Perl2EXE/PerlApp.

PAR是一个跨平台打包和部署工具,被称为Java的JAR和Perl2EXE / PerlApp之间的交叉。

#4


7  

From perlfaq3's answer to How can I compile my Perl program into byte code or C?:

从perlfaq3的回答我怎样才能将我的Perl程序编译成字节码或C?:


(contributed by brian d foy)

(由brian d foy提供)

In general, you can't do this. There are some things that may work for your situation though. People usually ask this question because they want to distribute their works without giving away the source code, and most solutions trade disk space for convenience. You probably won't see much of a speed increase either, since most solutions simply bundle a Perl interpreter in the final product (but see How can I make my Perl program run faster?).

一般来说,你不能这样做。有些事情可能对你的情况有用。人们通常会问这个问题,因为他们希望在不泄露源代码的情况下分发他们的作品,并且大多数解决方案为了方便而交换磁盘空间您可能也不会看到太多的速度增加,因为大多数解决方案只是在最终产品中捆绑Perl解释器(但是请参阅如何使我的Perl程序运行得更快?)。

The Perl Archive Toolkit ( http://par.perl.org/ ) is Perl's analog to Java's JAR. It's freely available and on CPAN ( http://search.cpan.org/dist/PAR/ ).

Perl Archive Toolkit(http://par.perl.org/)是Perl与Java JAR的类比。它可以在CPAN上免费获得(http://search.cpan.org/dist/PAR/)。

There are also some commercial products that may work for you, although you have to buy a license for them.

虽然您必须为他们购买许可证,但也有一些商业产品可能适合您。

The Perl Dev Kit ( http://www.activestate.com/Products/Perl_Dev_Kit/ ) from ActiveState can "Turn your Perl programs into ready-to-run executables for HP-UX, Linux, Solaris and Windows."

ActiveState的Perl Dev Kit(http://www.activestate.com/Products/Perl_Dev_Kit/)可以“将您的Perl程序转换为HP-UX,Linux,Solaris和Windows的可立即运行的可执行文件”。

Perl2Exe ( http://www.indigostar.com/perl2exe.htm ) is a command line program for converting perl scripts to executable files. It targets both Windows and unix platforms.

Perl2Exe(http://www.indigostar.com/perl2exe.htm)是一个命令行程序,用于将perl脚本转换为可执行文件。它针对Windows和unix平台。

#5


6  

And let's not forget ActiveState's PDK. It will allow you to compile UI, command line, Windows services and installers.

让我们不要忘记ActiveState的PDK。它将允许您编译UI,命令行,Windows服务和安装程序。

I highly recommend it, it has served me very well over the years, but it is around 300$ for a licence.

我强烈推荐它,多年来它一直很好用,但许可证大约300美元。

#6


5  

Note to Sinan and brian: perlfaq3 is still wrong.

思南和布莱恩注意:perlfaq3仍然是错误的。

See http://search.cpan.org/dist/B-C/perlcompile.pod

请参阅http://search.cpan.org/dist/B-C/perlcompile.pod

#7


3  

Cava Packager is great on the Windows ecosystem.

Cava Packager在Windows生态系统中非常出色。

#8


1  

Perl files are scripts, not executable programs. Therefore, for them to 'run', they are going to need an interpreter.

Perl文件是脚本,而不是可执行程序。因此,为了让他们“奔跑”,他们将需要一名翻译。

So, you have two choices: 1) Have the interpreter on the machine that you wish to run the script, or 2) Have the script running on a networked (or Internet) machine that you remotely connect to (ie with a browser)

因此,您有两种选择:1)在计算机上安装您希望运行脚本的解释器,或者2)让脚本在远程连接的网络(或Internet)计算机上运行(即使用浏览器)

#9


0  

On MaxOSX there may be perlcc. Type man perlcc. On my system (10.6.8) it's in /usr/bin. YMMV

在MaxOSX上可能有perlcc。输入man perlcc。在我的系统(10.6.8)上,它位于/ usr / bin中。因人而异

See http://search.cpan.org/~nwclark/perl-5.8.9/utils/perlcc.PL

请参阅http://search.cpan.org/~nwclark/perl-5.8.9/utils/perlcc.PL