Perl在Win32下的发行版本
2010-08-29 18:27:11 阿炯

ActivePerl(最广范,最易用(其ppm是所有版本中比较友好的,但更新较慢))
The granddaddy of them all and still the most popular production Perl distribution, ActivePerl from ActiveState. Also natively available for x64 architecture.它为windows、mac os、linux免费提供了ActivePerl,不过为solaris、hp-ux、aix提供的ActivePerl则要收取一定费用。

ActivePerl is the industry-standard, commercial-grade Perl distribution used by millions of developers around the world for easy Perl installation and quality-assured code. ActivePerl comes pre-compiled for out-of-the-box installation and includes core Perl binaries, popular modules, the Perl Package Manager (PPM) and complete documentation. Whether you're using Perl for mission-critical applications or open source projects, ActivePerl offers significant time savings over open source Perl for installing, removing, upgrading, and managing common Perl modules.ActivePerl comes in different editions to satisfy the spectrum of users - from large enterprises running Perl on distributed or critical applications to community developers building open source applications.

官方主页:http://www.activestate.com/activeperl/

Strawberry Perl-与Perl的发布版本同步更新,可从cpan或第三方上安装相关包,完全开源,使用较ActivePerl难些。
Strawberry Perl is intended as a variant of Vanilla Perl for experienced end-users.

A 100% Open Source Perl for Windows that is exactly the same as Perl everywhere else; this includes using modules from CPAN, without the need for binary packages.
It will provide a series of releases that come with Bundle::CPAN and some other improvements pre-installed (but only a relatively small number of them), for use by experienced Perl developers, and as a platform for CPAN authors to fix Win32 issues in their modules.

Strawberry Perl是一个用于MS Windows的Perl环境,其包含运行和开发Perl应用程序所需的所有内容。它被设计为尽可能接近UNIX系统上的perl环境,包括perl二进制文件、编译器(gcc)与相关工具、所有外部库(加密、数学、图形、xml…)、所有捆绑的数据库客户端以及其的所有功能。

2023年8月下旬在reddit上看到"Is Strawberry Perl dead?",才知道作者(briandfoy)已经转战GitHub-Perl-Dist-Strawberry,作者认为WSL(Windows Linux 子系统)似乎应该让Strawberry Perl变得不必要,但这实际上只适用于“超级用户”,他想说大多数使用Strawberry Perl的人都不能在这个级别上工作。从其主页上可以看到,自2021年1月的5.32版本构建之后到2023年7月的5.36的才有发行版本释出。Perl 5.36及其之后的Releases版本均可通过此处下载。


官方主页:http://strawberryperl.com/

项目主页:https://github.com/StrawberryPerl/Perl-Dist-Strawberry


ActiveState is built via Visual Studio/vcc.

Strawberry is built via Gnu (gcc).

其发行方式有如下4种:

MSI installer
preferred way, requires admin privileges to install
首选方式,需要管理员权限才能安装

ZIP edition
admin privileges not required, however you need to run some post-install scripts manually after unzip
不需要管理员权限,但是您需要在解压缩后手动运行一些安装后脚本

Portable edition
suitable for "perl on USB stick" (you can move/rename the perl directory and it will still work)
适用于“U盘上的perl”(便携版本,您可以移动/重命名perl目录,它仍然可以工作)

PDL edition
portable edition + extra PDL related modules and external libraries
便携版+额外的PDL相关模块和外部库

Portable 与 PDL 版本安装使用参考

此两个版本通常与直接安装版本一起发布,适用于不便安装的情况,这里重点对它俩的使用做一些介绍。其自带 Gcc 编译环境 ( 解压路径\Strawberry\c ),\vendor\lib 目录包含诸多实用模块:Crypt::CBC, Digest, Imager, Mojo, Moose, OpenGL, Win32::GuiTest, Prima(GUI), YAML, JSON ... 自带 PDL, wgnuplot, Graphviz 等...

环境配置

由于是便携版,环境变量和文件关联还是得自己设置,这里假设解压目录为 C:\,参考路径为 C:\Strawberry\perl。

文件关联以及图标

以下内容可以保存为批处理执行(须使用管理员权限)
@echo off
assoc .pl=Perl
ftype Perl=C:\Strawberry\Perl\bin\perl.exe "%%1" %%*
reg del HKCR\Perl\DefaultIcon 2>nul
reg add HKCR\Perl\DefaultIcon /f /d C:\Strawberry\win32\metacpan.ico

assoc .wpl=wperl
ftype wperl=C:\Strawberry\Perl\bin\wperl.exe "%%1" %%*
reg del HKCR\wperl\DefaultIcon 2>nul
reg add HKCR\wperl\DefaultIcon /f /d C:\Strawberry\win32\metacpan.ico

环境变量

C:\Strawberry\c\bin;
C:\Strawberry\perl\bin;
C:\Strawberry\perl\site\bin;

将以上路径添加到系统或者当前用户的 %PATH% 变量,其中

第一项是编译模块需要用到的 Gcc 等一众开发编译工具的 bin 目录,以及某些脚本运行时会用到的动态库。

第二项路径含有 Perl 解释器、调试器 以及一些默认模块的附带工具。

第三项是用户安装模块的附带工具的路径,比如: win32-gui-demos.bat, perldoc.bat, nytprofhtml。

修改模块安装源

编辑 C:\Strawberry\perl\lib\CPAN\Config.pm

在 @urllist 中添加 163 的CPAN镜像

my @urllist = (
   'http://mirrors.163.com/cpan/',
  'http://cpan.strawberryperl.com/',
);

编译模块

为了提高成功率,编译前运行 C:\Strawberry\portableshell.bat 以确保 strawberry 提供的 gcc 环境优先。

Sublime Text 运行配置

perl.sublime-build
{
    "path": "C:/Strawberry/perl/site/bin;C:/Strawberry/perl/bin;C:/Strawberry/c/bin;C:/windows/system32",
    "cmd": ["cmd", "/c", "$file"],
    "file_regex": ".* at (.*) line ([0-9]*)",
    "selector": "source.perl",
    "encoding": "gbk"
}


遇到的问题

perldoc 提示 "无效参数"

解决方法:cpan install Pod::Perldoc


ActiveState Perl 和 Strawberry Perl 最大的区别是后者包含多一些 CPAN 里的模块,所以 Strawberry Perl 下载的安装文件有100多M,而 ActiveState Perl 只有20M左右。

ActiveState Perl: ActiveState提供了一个免费的社区版本和一个商业支持的Perl用于Win32和Perl的二进制发行版本。

Strawberry Perl:用于Windows的100%开源Perl,使用来自CPAN的模块不需要二进制包。

ActivePerl含了包括有四套开发工具程序:Perl for Win32、Perl for ISAPI、PerlScript、Perl Package Manager

这些开发工具可以让用户编写出适用于unix,windows,linux系统的的CGI程序,使用Perl Package Manager来管理包 ppm install xxx.ppd。

在Unix系统默认都有安装Perl 的编译器,Windows上还有一个常见的是Cygwin的Perl。


Citrus Perl is a binary distribution of Perl with pre-built modules for wxPerl built against both the wxWidgets 2.8.x stable branch and the latest 2.9.x development branch. 它为程序员开发的一个Perl分支版本,带有预构建的模块,用于生成包含稳定分支和发展处针对 wxPerl 的GUI包,此外开发人员可以轻松地扩展软件。可为MS Windows, Linux and MacOSX用户提供使用。与Perl一样,采用Artistic License协议授权。其最新版本停留在2017年的Perl 5.24版本处,关联的wxPerl网站亦是如此。

The current release version of Citrus Perl is built with Perl 5.24.1. It is targetted at users wishing to develop wxPerl GUI applications or Tk users wishing to migrate. Other modules provided include: DBD::Pg DBD::mysql DBD::SQLite Tk GD The main distributions are provided as archives named in the format.
 
官方主页:http://www.citrusperl.com/


Vanilla Perl
Vanilla is an entirely experimental distribution that serves as a testing ground for issues related to Windows and the Perl code, and issues relating to the installation toolchain (CPAN.pm, et al).Vanilla Perl is never expected to be useful for end users.The Vanilla Perl Project is an experiment to provide binary Perl distributions for the Microsoft Windows operating system that include a bundled compiler. Bundling a compiler provides the ability to install XS CPAN modules directly from CPAN, making the Win32 Perl development more akin to Unix perl development.

CamelPack
Installer for ActivePerl, Dev-C++, and nmake.


Historical Note: This distribution was created in only 2 days, and won the creator a "vertical Metre of beer".

SiePerl
Built for Win32 by Siemens, contains several modules.

官方主页:http://www.cpan.org/authors/id/G/GR/GRAHAMC/

PXPerl
Compiled with Intel C++ Compiler for maximum performance, lots of modules already installed, with Pugs and Parrot binaries, lets you install any other module from CPAN.Historical Note: It was the creation and subsequent stalling of this distribution that led to the "Vertical Metre of Beer" competition which spawned both the CamelPack and Vanilla Perl.

nsPerl

"NetScape Perl",This was produced by some employees of the old Netscape, but is now completely out of date.

官方主页:http://people.netscape.com/richm/nsPerl/


----------------------
Combination Distributions
Distributions that contain Perl in addition to a number of other diverse things.

Cygwin
Cygwin is a port of popular open source GNU and UNIX tools to the Win32 platform and provides a Linux-like environment. A pre-built version of Perl is included in the Cygwin distribution.See README.cygwin, or "perlcygwin" perldoc or man page.


From the Cygwin Setup only some Win32 perl packages are prebuilt: perl, libwin32, Win32::GUI, Win32::API, perl-Tk-804.027 (for Cygwin X11 only!), ExtUtils::Depends, ExtUtils::PkgConfig, perl_manpages.
The rest should build via CPAN out of the box.Because Cygwin Perl is on a platform that is partly Linux-like and partly Windows, it has a tendency to suffer from corner case bugs in unexpected places.

IndigoPerl
A binary build of Perl, Apache and PHP for Windows.
Historical note: IndigoPerl was the first competitor to ActivePerl.

官方主页:http://www.indigostar.com/indigoperl.htm

TinyPerl



TinyPerl使用一组“魔法”使其自身更为紧凑。所有二进制文件(dll,so,exe)都用UPX压缩,而Lib(./Lib目录)则保持在Lib.zip压缩文件中。为了使用lib.zip文件,使用了模块LibZip。该发行版本主要用于摆脱Perl运行环境而生成独立的可执行文件;与其他类似的标准模块相比(如PAR),LibZip的优势在于独立性和尺寸。LibZip的文件被附加在可执行文件中,解压缩文件所需的Compress::Zlib的XS在PerlLib(Perl58.dll)中静态编译,避免了额外的文件依赖。其授权与Perl本身相同。

特点

Modules: It comes only with the basics to run, this means: Carp, Dynaloader, Exporter, IO, PerlIO, Socket, strict, utf8, vars, warnings, XSloader... (see inside lib.zip)

XS: Enabled from version 1.1 of LibZip. When a module that uses XS files are loaded all the content of lib.zip/lib/auto/FOO is extracted to ./libzip-tmp directory.

lib.zip and ./lib: You can use the both ways, lib.zip file and ./lib directory, in the same time.

libzip-tmp: This is the directory where temporary files of LibZip are extracted. When TinyPerl goes out it cleans the directory (except files that are used in the moment). If 2 TinyPerl are running in the same time they will share the extracted files, saving load time.

最新版本是2003年1月发布的2.0 beta 版本(基于PerlV5.8),从SF站点提供的下载文件看,确实非常小,符合其Tiny的特性。单纯从技术的角度来说,这是非常有技术难度的。

项目主页:https://tinyperl.sourceforge.net/


另有基于其的PerlBin项目?



Camelbox
A complete build of Perl for 32-bit Windows that includes:
* A nice Windows installer that automatically downloads and installs the correct archive files
* All of the core Gtk2-Perl modules (Gtk2, Glib, Cairo), as well as their equivalent C libraries compiled for Windows.
* A working CPAN module
* Bonus (!) Perl modules, including DBI/DBD[SQLite|mysql|Pg|ODBC] and friends
* Extra binaries, utilities, development libraries/headers for compiling even more Perl modules from CPAN
* Lots of Perl/GTK documenation in HTML format
* Windows shortcuts for applications, demos, documentation, and links to doumentation/tutorials on the web

all neatly packaged and ready to install,笔者认为这是一个对Gtk2环境集成的最好的一个开发环境了,但也许久没有更新了。

官方主页:http://code.google.com/p/camelbox/

Apache Perl
Has prebuilt binaries for two mod_perl environments.

* Perl 5.6.1, Apache 1.3.27, mod_perl-1.27
* Perl 5.8.7, Apache 2.0.54, mod_perl-2.0.1

DeveloperSide.Net
Compiled under VS.NET and includes the latest versions of Apache2, PHP, MySQL, OpenSSL, mod_perl, Apache::ASP, and a few other components.

官方主页:http://www.devside.net/


Randy Kobes Perl
A binary Perl installer by Randy Kobes. Keeps pace with current perl releases.


Based on ActivePerl so also supports ppm, which Randy provides his own ppm repository for.Bundles apache2, mod_perl, mod_ssl, php, and some other popular modules.

官方主页:http://theoryx5.uwinnipeg.ca/pub/other/

本文参考:http://win32.perl.org/wiki/index.php?title=Win32_Distributions

---------------------------------------------------------------
Perl脚本转为独立的可执行文件

1、首推Roderich SchuppPAR系列模块。

$ pp -o hello hello.pl

这样生成的hello就是可执行文件,而且把用到的perl模块文件也全打包进来了。运行的时候它会在/tmp/par-username/下生成一个叫 cache-MD5之类的临时文件夹,打开看就可以发现就是自己的源代码。这样不是没达到想要的隐藏源代码的目的么?

原来还需要启动过滤器:
$ pp -f Bleach -o hello hello.pl
或者
$ pp -f Bytecode -o hello hello.pl

前面的Bleach过滤器是PAR自己实现的,而Bytecode这种过滤方式是Perl的标准格式(需要Perl 5.8.1
以上版本支持)。过滤之后,临时文件夹里面的文件就不是简单可读了。

2、Perl2Exe

这是共享软件,需要购买。转换后的大小和转换速度都优于其他。

3、TinyPerl

比较久远了,更新还停留在2003年,还是不用了吧。



该文章最后由 阿炯 于 2024-09-25 14:03:02 更新,目前是第 2 版。