views:

81

answers:

2

I'm integrating with some existing, "legacy" Perl code for my current project. I'm downloading some libraries via CPAN to use in a Perl script, but I would like to avoid having all the other developers/users install these libraries manually. Taking a page from my Ruby/Rails background, I thought it might be possible to "unpack" the dependencies to a local directory that's under version control and then load the libraries from there. The advantages are that (1) no one has to install specific packages manually and (2) you know everyone has the same version and can update that version easily.

I tried the easy approach and just moved the installation files to ./vendor/Perl/Pod/, ./vendor/Perl/DBD/, ./vendor/Perl/Win32/, etc and adjusted @INC accordingly. This worked fine for some libraries but not others. I would guess compiled libraries are causing problems, as well as dependencies.

Is there already a solution out there that solves this problem for me? The core of it is that I don't want to manually manage dependencies between developers or users (which we have to do now).

I'm not terribly familiar with Perl, so I apologize for my ignorance in advance.

+4  A: 

I would use local::lib for this. It sets up environment variables for you, then you can install CPAN modules as normal and have them installed in a local directory.

Then just share the environment variables with the other developers.

Edit

You've commented that different users are using different operating systems. The compiled modules will need to be recompiled for each system.

I still suggest using local::lib. Combine it with a makefile for your project that will install the dependencies you need. (Assuming the Windows users use Strawberry Perl)

David Dorward
That sounds like a very good option -- I'll check it out. Unfortunately, the Windows people are using ActiveState Perl, so I'm not sure what's applicable in that case.
Benjamin Oakes
Have them upgrade to Strawberry? :) Perl 5.12 *is* just around the corner, and going between versions is a great incentive to switch to a different distribution.
Robert P
With ActiveState Perl you'll need to look to them for what compiler can be used to build XS related modules. At one point in time there was a free compiler that would work. I also highly recommend looking at Strawberry Perl. It is the closest thing to having a the same Perl experience on Windows as you get on a Unix.
perigrin
You can install `mingw` through `ppm` if you are using ActiveState Perl. I am happy to report that it works beautifully.
Sinan Ünür
+2  A: 

The current directory is part of the module search path. So you can put modules directly into your project's tree. The problem is that . comes last in the list of directories to search. So if another version of some module is installed on a system, you will get unexpected upgrades/downgrades. This is obviously not desirable.

Fortunately there are many ways to work around this issue. You could:

daotoad