Search code examples
perlsoaplite

Is there a way to have two versions of a same Perl library in parallel?


I would like to migrate a perl library (SOAP::Lite) used by my application. To to the migration as smoothly as possible for the end-users, I would like to have the two versions of this library (the old one and the new one) to work in parallel.

The goal is to let the end-users migrate their scripts (if needed) by themselves, whenever they want. So basically, for the old scripts the users would have nothing to change, and the new scripts would be written using the new version.

Does anyone know a way to proceed ?


Solution

  • Since, as you mentioned in the comments, each script is called by a Java application that asks as a scheduler, you don't need both modules "at once". Instead, you simply need one or the other for each run of a script. This can be handled by setting the environment appropriately as an old or new script is called.

    You could use solutions such as Perlbrew to manage two or more completely different Perl installations, if you wish. This would be a good approach if you find that you want other differences between the old and new versions.

    However, if you simply want to swap out versions of this one module, all you need to do is have both installed somewhere, and alter the module path when you call the script. There are various ways to do this, but you could just use a command-line switch:

    perl -Idirectory script.pl
    

    This will add directory to @INC, the set of locations where modules are searched for. Point to the old or new module as appropriate (if you do it this way, make sure that neither version of the module is in the standard module path, otherwise there will be ambiguity as to which version you are using).