Introduction

This 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? ;-)

Installing 5.8.0

#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
Summary of my perl5 (revision 5 version 8 subversion 0) configuration: ... Locally applied patches: ActivePerl Build 802 Built under MSWin32 Compiled at Nov 8 2002 00:54:02 @INC: C:/Perl-5.8.0/lib C:/Perl-5.8.0/site/lib .

Making Scripts Use the Perl You Want

Windows, 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:
if ($^V eq v5.6.1) { print "I found version 5.6.1!\n"; } if ($^V eq v5.8.0) { print "I found version 5.8.0!\n"; }
Release notes and such should be in C:\Perl-5.8.0\html\index.html once you've installed.

Dealing With Modules

Perl 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 From

Notes 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

In reply to Using Multiple Versions of ActivePerl, or I Want to Use ActivePerl 5.8.0 But Not Break My ActivePerl 5.6.0 by ibanix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.