May I use Strawberry Perl and ActiveState Perl simultaneously on one computer?
Asked Answered
W

4

9

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?

Wolframite answered 2/4, 2012 at 8:7 Comment(1)
Re "Due to some reason": Do you mean "Due to the same reason"?Physicalism
C
5

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.

Clisthenes answered 2/4, 2012 at 8:43 Comment(1)
Thanks for your clarifications! So if in the environmental path Active State perl has priority and I want to use Strawberry one, then how should I do? May I do like what 'Saiful' said, in the perl script specifying #!C:\strawberry\perl\bin\perl? Or is there a more advised solution? Thank you!Wolframite
L
3

I keep both ActivePerl and Strawberry Perl installed on my Windows 7 Pro instance. My PATH variable order decides my Perl preference. E.g, 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
Lahey answered 2/4, 2012 at 8:50 Comment(2)
If I recall correctly the shebang is ignored in windows. Am I correct?Studdingsail
It is ignored by windows, but when the default perl gets to parse the file it will then pass control to the program mentioned in the shebang line.Deutschland
S
2

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/

Studdingsail answered 2/4, 2012 at 8:41 Comment(1)
AS version requires Business Edition Perl. There's now berrybrew tool available for Strawberry Perl.Tearoom
S
0

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
Studdingsail answered 11/4, 2012 at 8:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.