在 Windows 上使用 perl 脚本而不安装 ActivePerl?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5869118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:47:03  来源:igfitidea点击:

Using a perl script on windows without installing ActivePerl?

windowsperlinstallation

提问by Martin Ba

I'm using Perl as my scripting language of choice under Windows and normally I just install ActivePerl(mostly 5.8 for personal legacy reasons) and be done with it.

我在 Windows 下使用 Perl 作为我选择的脚本语言,通常我只安装ActivePerl(出于个人遗留原因,主要是 5.8)并完成它。

I now face the problem that I'd like to use some small scripts on a machine where I do not have any admin rights and therefore cannot install the ActiveState distribution with its installer.

我现在面临的问题是,我想在没有任何管理员权限的机器上使用一些小脚本,因此无法使用其安装程序安装 ActiveState 发行版。

What needs to be zipped together from an installed ActiveState Perl to do an xcopy-style installation of Perl on Windows? (And which environment variables will then have to be set in a command shell to make it work?)

什么需要从已安装的 ActiveState Perl 中压缩到一起才能在 Windows 上执行 xcopy 风格的 Perl 安装?(然后必须在命令外壳中设置哪些环境变量才能使其工作?)

回答by Quentin

Strawberry Perlhas a portable edition. I'd use that in preference to trying to hack ActivePerl into working without being properly installed.

Strawberry Perl有一个便携版。我会优先使用它,而不是尝试在没有正确安装的情况下将 ActivePerl 破解为工作。

回答by Jan Dubois

You can install ActivePerl without admin rights by using the *.zip file installer instead of the *.msi. Download from the ActivePerl 5.26.3 download directoryand run the installer.batfile in the root of the extracted tree.

您可以在没有管理员权限的情况下使用 *.zip 文件安装程序而不是 *.msi 来安装 ActivePerl。从ActivePerl 5.26.3 下载目录下载installer.bat在提取的树的根目录中运行该文件。

回答by Sinan ünür

PAR::Packerallows you to pack perlalong with your scripts and modules it depends on in a standalone executable. You might want to double-check ActiveState's license terms to make sure this type of distribution is allowed.

PAR::Packer允许您将perl它依赖的脚本和模块打包在一个独立的可执行文件中。您可能需要仔细检查 ActiveState 的许可条款,以确保允许这种类型的分发。

回答by Martin Ba

Strawberry Perl from David's answermight be the best solution as it officially supports xcopy installation.

来自大卫回答的草莓 Perl可能是最好的解决方案,因为它正式支持 xcopy 安装。

However, I have now just tried copying the installation directory C:\Perlof ActiveState and when C:\Perl\binis added to PATHit seems to execute my script(s) just fine.

但是,我现在刚刚尝试复制C:\PerlActiveState的安装目录,当C:\Perl\bin添加到PATH它时似乎可以很好地执行我的脚本。

Obviously, you have to run scripts via __> perl file.plas no file association exists for Windows to know how to call just __> file.plas it would when using the installed version, but you always have to do that with xcopy-installs.

显然,您必须通过运行脚本,__> perl file.pl因为 Windows 不存在文件关联才能知道如何调用,就像__> file.pl使用已安装版本时一样,但您始终必须使用 xcopy-installs 来执行此操作。

I have also inspected the MSI installer from ActiveState (for 5.8) and it only contains files that are installed to TARGETDIR\Perlso I think just copying the Perl directory should also be safe for ActiveState.

我还检查了 ActiveState 的 MSI 安装程序(适用于 5.8),它仅包含安装到的文件,TARGETDIR\Perl因此我认为仅复制 Perl 目录对于 ActiveState 也应该是安全的。

回答by TLP

From what I hear, ActivePerl can be tricky to handle this way.. however, I found this at perlmonks:

据我所知,ActivePerl 处理这种方式可能很棘手.. 但是,我在 perlmonks 上发现了这一点:

http://www.perlmonks.org/?node=Portable%20perl%3A%20usb%20thumbdrive

http://www.perlmonks.org/?node=Portable%20perl%3A%20usb%20thumbdrive

In short: Guy wants perl on windows without admin rights, so he makes a usb thumbdrive that does the job.

简而言之:Guy 想要在没有管理员权限的 Windows 上使用 perl,所以他制作了一个 USB 拇指驱动器来完成这项工作。

回答by Kalpesh Patel

Here is the link where you can get portable perl edition. http://strawberryperl.com/releases.html

这是您可以获得便携式 perl 版本的链接。 http://strawberryperl.com/releases.html

Here are some Explanatory Notes from the page where you can fine different installation files. e.g MSI, ZIP etc

以下是页面中的一些说明,您可以在其中细化不同的安装文件。例如 MSI、ZIP 等

MSI installer = preferred way, requires admin privileges to install

MSI 安装程序 = 首选方式,需要管理员权限才能安装

ZIP edition = admin privileges not required, however you need to run some post-install scripts manually after unzip

ZIP 版本 = 不需要管理员权限,但是您需要在解压后手动运行一些安装后脚本

PortableZIP edition = suitable for "perl on USB stick" (you can move/rename the perl directory and it will still work)

PortableZIP 版本 = 适用于“USB 记忆棒上的 perl”(您可以移动/重命名 perl 目录,它仍然可以工作)

MSM merge module = for advanced users who want to build their own MSI based on Strawberry Perl

MSM 合并模块 = 适用于希望基于 Strawberry Perl 构建自己的 MSI 的高级用户

DDrive edition = (not used since 5.12 series) special edition with fixed install path to d:\strawberry

DDrive 版本 =(从 5.12 系列起不再使用)特别版,安装路径固定到 d:\strawberry