HOW TO SET UP A NETWORKED WIN32 ACTIVESTATE PERL

Update

These notes were written at a time when the ActiveState MSI installer refused to install to a UNC (network) path; it insisted on a path beginning with a drive letter. Since then this restriction has been removed and it's now possible to install ActivePerl directly to your UNC location. However, there are a few things I don't like about the direct install so I continue to prefer the technique described below. The problems are:
  1. The installer insists in sticking an extraneous "Perl" into any install path you give it. I.e. if you tell it to install to \\fileserver\Perl you'll find the result in \\fileserver\Perl\Perl. And since \\fileserver by itself isn't a valid UNC path, there's no way to trick it into doing the right thing. If you're picky about not having a redundant or (at the least) overly long path to Perl, you'll end up using the reloc_perl script as described below anyway, and thus the direct install ends up buying zilch.
  2. It remembers in the registry that Active Perl has been installed on this machine, even though the whole point was to install to a non-machine-specific location. I discovered this when I tried to install a local copy after the network one in order to benchmark them against each other. The installer "knew" that Perl was already installed and refused to let me install "again". By the same token, the direct install will leave a program group folder on the installing PC. Not everyone will care about these warts, but the install-copy-modify-uninstall procedure below leaves the host PC entirely pristine, i.e. the same as it was before and no different from any other PC in your network vis-a-vis ActivePerl. And that's the goal.

However, if you want to keep it really simple and don't care about the above, a potential command line (as contributed by David Baird) would be something like:

start /wait msiexec /i ActivePerl-XXX.msi TARGETDIR="\\fileserver\netperl" ADDLOCAL="PERL_FEATURE,PPM" /qr /l instlog.txt

I don't know whether the GUI install allows a UNC path to be specified or browsed to.

Installation

This is really quite simple: we will install ActivePerl to a local drive, copy it to a network drive, use the reloc_perl script to update the network copy's understanding of its new location, and uninstall the local copy.

Slash Style

In late 2003 I received the following note from David Baird.

I tested both forward slashes (/) and backslashes (\) for the new location of Perl, and found that in both cases, the @INC is written with forward slashes (/). Also, backslashes are written to the .bat files in the Perl directory for the perl.exe command. It seems not to make a difference what you enter.

Binary vs text relocation

UNIX perl builds have historically compiled the value of @INC into the binary program, so localizing them would require recompilation or binary editing. ActiveState Win32 perl, however, has a feature such that it autodiscovers its install location at runtime. Thus, though reloc_perl is capable of modifying binaries, on AS Win32 builds it should only need to modify text files such as Config.pm. I'm not sure if this autodiscovery is a property of AS perl or a feature of all recent (5.6.1+) Perls.

Interop and Maintenance

If using this configuration in combination with a UNIX-aware SMB interop solution such as Samba, and assuming you have a UNIX Perl installation too, module maintenance can be greatly eased by creative use of symlinks. Let's say you want to use the ClearCase::ClearPrompt module. First install it to your UNIX perl. Let's say it ends up in /usr/local/lib/perl5/site_perl/5.6.0/ClearCase/ClearPrompt.pm. Now, on the UNIX box, go to your Win32 perl install area and symlink .../site/lib/ClearCase to /usr/local/lib/perl5/site_perl/5.6.0/ClearCase. From now on you can install updates to this module (or in fact to any modules in the ClearCase:: namespace) on the Unix side and they'll automatically apply to the Windows perl as well. You can symlink individual files or whole hierarchies as preferred. Module updates must be handled from the Unix side in this scenario, because Win32 perl can handle Unix line termination style while the reverse is not true.

To run scripts with a networked Win32 perl, I do not recommend using pl2bat or registering the .pl extension. Both of these present maintenance headaches. Instead, I use a tiny redirector program as follows:
@echo off
\\fileserver\netperl\bin\perl \\server\share\program %*
If you play your cards right this can point to the exact same script you use on UNIX. I.e. \\server\share\program can be an SMB access to the same file found via UNIX NFS as (say) /usr/local/bin/program. In future, when you update the UNIX script it will take effect on Windows automatically. The redirector itself should never need maintenance because it's 100% boilerplate.

Configuring and using the CPAN module or PPM (the ActiveState install mechanism) is left as an exercise for the reader. Be aware that both need some special setup to work within firewalls. I have some notes on PPM setup contributed by David Baird.