简体   繁体   English

我可以在一台计算机上同时使用 Strawberry Perl 和 ActiveState Perl 吗?

[英]May I use Strawberry Perl and ActiveState Perl simultaneously on one computer?

I used to delete my ActivePerl once, and all the installed modules were lost.我曾经删除过一次我的ActivePerl ,所有安装的模块都丢失了。 So now I am very careful with this kind of issue.所以现在我对这种问题非常小心。 Due to some reason, I want to use Strawberry Perl now, while keeping ActiveState's ActivePerl in use.由于某种原因,我现在想使用Strawberry Perl ,同时保持使用 ActiveState 的 ActivePerl。

Will this cause compatibility issues?这会导致兼容性问题吗? Is it advisable?是否可取?

This will not be a problem as both the Perl implementations will look at different directories for modules.这不会成为问题,因为两个 Perl 实现都会查看不同的模块目录。 That is, the @INC entries will be different.也就是说, @INC条目会有所不同。

I keep both ActivePerl and Strawberry Perl installed on my Windows 7 Pro instance.我在 Windows 7 Pro 实例上同时安装了ActivePerlStrawberry Perl My PATH variable order decides my Perl preference.我的 PATH 变量顺序决定了我的 Perl 偏好。 Eg, for using ActivePerl I set my PATH to something like this:例如,为了使用 ActivePerl,我将 PATH 设置为如下所示:

C:\Perl64\bin;C:\strawberry\perl\bin

You can always override this in your script using shebang:您始终可以使用 shebang 在脚本中覆盖它:

#!C:\strawberry\perl\bin\perl

You could use two (many) different Perl versions at once.您可以一次使用两个(许多)不同的 Perl 版本。

Set your PATH variable to include your primary Perl path (path to perl.exe) to be sure that you are running the correct Perl when you start a program with perl script.pl .将 PATH 变量设置为包含主要 Perl 路径(perl.exe 的路径),以确保在使用perl script.pl启动程序时运行正确的 Perl。

You could use Perlbrew (or other modules) to help keeping multiple Perl installations on your computer.您可以使用Perlbrew (或其他模块)来帮助在您的计算机上保持多个 Perl 安装。

It is available on Windows: http://code.activestate.com/ppm/App-perlbrew/它在 Windows 上可用: http : //code.activestate.com/ppm/App-perlbrew/

I found another solution for this.我为此找到了另一个解决方案。 You could embed your Perl code into a Windows batch file.您可以将 Perl 代码嵌入到 Windows 批处理文件中。 This way you could set environment variables before executing your Perl script or include your module path.通过这种方式,您可以在执行 Perl 脚本或包含模块路径之前设置环境变量。

@echo off
cd %TEMP%
set perl_bindir=C:\strawberry\perl\bin
set module_dir=C:\my_perl_modules
set path=%perl_bindir%;%path%

echo Launching %0 perl script

%perl_bindir%\perl.exe -I %module_dir% -x -S %0 %*
goto endofperl

#!perl -w

use strict;
print "Hello World\n";

__END__
:endofperl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM