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?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Qiao Zhou
  • 149
  • 1
  • 4

4 Answers4

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.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Alan Haggai Alavi
  • 67,398
  • 19
  • 96
  • 124
  • 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! – Qiao Zhou Apr 02 '12 at 10:00
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
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Saiful
  • 144
  • 2
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/

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
user1126070
  • 4,999
  • 1
  • 14
  • 14
  • AS version requires Business Edition Perl. There's now [berrybrew](https://github.com/dnmfarrell/berrybrew) tool available for Strawberry Perl. – flamey Feb 11 '15 at 21:52
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
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
user1126070
  • 4,999
  • 1
  • 14
  • 14