简体   繁体   中英

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. 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.

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. That is, the @INC entries will be different.

I keep both ActivePerl and Strawberry Perl installed on my Windows 7 Pro instance. My PATH variable order decides my Perl preference. Eg, for using ActivePerl I set my PATH to something like this:

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

You can always override this in your script using shebang:

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

You could use two (many) different Perl versions at once.

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 .

You could use Perlbrew (or other modules) to help keeping multiple Perl installations on your computer.

It is available on 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. This way you could set environment variables before executing your Perl script or include your module path.

@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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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