|XP is just a number|
Using Multiple Versions of ActivePerl, or I Want to Use ActivePerl 5.8.0 But Not Break My ActivePerl 5.6.0by ibanix (Hermit)
|on Dec 02, 2002 at 04:39 UTC||Need Help??|
IntroductionThis is a short writeup on using two (or more!) ActivePerl distributions at the same time.
I didn't find a node on this topic so I am writing this to the best of my knoweldge.
Feedback and/or corrections are welcomed. Thanks to the CB folks for helping with this!
Note: Where I say "Perl 5.8.0" you can insert any ActivePerl version.
Why?* You want to use Perl 5.8's new features.
* You want to test compatability of your scripts with 5.8.
* You have multiple ActivePerl distributions in production and you need to check compatability against all of them.
* Do you really need another reason? ;-)
#1: Download the ActivePerl 5.8.0 distribution. Note that this is still considered Beta!
The MSI installer is prefered, as it will easily install/deinstall.
#2: Run the installer. Be sure to change the install path to a location other than your current Perl install path!
Your current install path can be found from a comand line with perl -V.
On my systems I have ActivePerl 5.6 at C:\perl-5.6.0 and ActivePerl 5.8.0 at C:\perl-5.8.0. Pretty obvious, really.
When you reach the dialogue box asking you if you add the Perl binary to %PATH%, do not do so. De-select all of the options, unless you want to use Perl 5.8.0 by default. The IIS and ISAPI options will also override the current settings, so don't select them unless you want 5.8.0 to be used by default. Finish the installation.
#3: Now you should have ActivePerl 5.8.0 installed. Confirm you can use by running C:\perl-5.8.0\bin\perl.exe -V and you should get
Making Scripts Use the Perl You WantWindows, in typical fashion, does not support shebang (#!) options in scripts, so we will not be able to put #!C:\perl-5.8.0\bin\perl.exe at the top of our scripts. Pity. However, there are a few workarounds:
Workaround #1: Batchfiles
Create a batchfile (.bat) that calls your script with the desired perl binary, eg. C:\perl-5.8.0\bin\perl.exe myscript.pl. Then run the batchfile.
Workaround #2: File Extensions
Using the ftype and assoc commands, you can set what file extensions call which binaries.
Note: This works on Windows 2000, and I assume it works on Windows NT and Windows XP. No idea if it works on any other versions.
First, setup a filetype like so: ftype perl_58_script="C:\perl-5.8.0\bin\perl.exe" "%1" %*,
then associate it with a file extension: assoc .p58=perl_58_script.
That's it! foo.p58 should now use perl 5.8.0
You can confirm that your script is using the perl version you want by testing the $^V variable. See perlvar. In general, this should work:
Release notes and such should be in C:\Perl-5.8.0\html\index.html once you've installed.
Dealing With ModulesPerl 5.8.0 is binary incompatible with earlier perl versions, so XS modules will need re-compilation. In addition, if you need a module for perl 5.8.0, you will need to redefine @INC to include your previous module dirs (which one hopes are compatible). This is probally dangerous.
The better but tedious option is to install the modules for perl 5.8.0 seperately. The Perl Package Manager is the default way of doing this with ActivePerl. To call the PPM for 5.8.0, specify the full path to it: C:\perl-5.8.0\bin\ppm. Note that 5.8.0 uses PPM 3; if you like PPM 2 better, use C:\perl-5.8.0\bin\ppm2
Nodes I Stole Stuff FromNotes on Upgrading to 5.8.0 on a production web server
Happy Win32 Perl-ing!
Update: Fixed "%l" to be "%1".
Note that the method of using ftype and assoc can also be found on page 5 of Dave Roth's excellent book,
Win32 Perl Scripting: The Administrator's Handbook