Ogbert has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone,

Hope this is not too dumb a post, but I've got a question about upgrading perl and how this works with pre-existing modules on a system. I've tried searching on google and on perlmonks for advice but not found an answer, hence my mail.

The question is: is there any way of using modules installed before an upgrade without having to reinstall all the modules?

The scenario is:

We've just upgraded from v5.005_03 to v5.8.0, and we have a few modules within the @INC for 5.005_03.

From the documentation that comes with the v5.8 installation, the impression I get is that module directories for previous installs of Perl will be searched after an upgrade. Below is a quote from the doc:
~~~~~~~~~~~~~~~~~~
This way, modules installed under 5.005_03 will continue to be usable by 5.005_03 but will also accessible to 5.6.0. Further, suppose that you upgrade a module to one which requires features present only in 5.6.0. That new module will get installed into /usr/local/lib/perl5/site_perl/5.6.0 and will be available to 5.6.0, but will not interfere with the 5.005_03 version.
~~~~~~~~~~~~~~~~~~~

Unfortunately, that's not what I'm finding on our system.

The @INC's for our versions are:
$ /usr/opt/perl5/bin/perl5.00503 -e 'for (@INC) {print "Inc: \"$_\" \n"}'
Inc: "/usr/opt/perl5/lib/5.00503/aix"
Inc: "/usr/opt/perl5/lib/5.00503"
Inc: "/usr/opt/perl5/lib/site_perl/5.005/aix"
Inc: "/usr/opt/perl5/lib/site_perl/5.005"
Inc: "."
$ /usr/opt/perl5/bin/perl5.8.0 -e 'for (@INC) {print "Inc: \"$_\" \n"}'
Inc: "/usr/opt/perl5/lib/5.8.0/aix"
Inc: "/usr/opt/perl5/lib/5.8.0"
Inc: "/usr/opt/perl5/lib/site_perl/5.8.0/aix"
Inc: "/usr/opt/perl5/lib/site_perl/5.8.0"
Inc: "/usr/opt/perl5/lib/site_perl"
Inc: "."

If I run a test script with a module that I installed under 5.005_03, I get this error:

$ new_version_test.pl Can't locate Config/IniFiles.pm in @INC (@INC contains: /usr/opt/perl5 +/lib/5.8.0/aix /usr/opt/perl5/lib/5.8.0 /usr/opt/perl5/lib/site_perl/ +5.8.0/aix /usr/opt/perl5/lib/site_perl/5.8.0 /usr/opt/perl5/lib/site_ +perl .) at new_version_test.pl line 10. BEGIN failed--compilation aborted at new_version_test.pl line 10.
*stares vacantly at screen at prospect of reinstalling lots of modules*

Any chance I can still use the old modules under 5.8?

Thanks very much for your help.

Mark

Edit by tye, put CODE tags / drop BR for lines that IE won't fold

Replies are listed 'Best First'.
Re: perl 5.8 upgrade - @INC problem
by chromatic (Archbishop) on Sep 23, 2003 at 18:19 UTC

    If you have any modules with compiled components, they likely won't work with the new version of Perl, for various versions of "won't work" including "will crash", "will not start", and "will throw out lots of error messages while not starting and right before crashing".

    Fortunately, if you have CPAN installed (and you most likely do), you can use the autobundle feature to get a snapshot of what you have installed, making it much easier to install the modules on the new version. It's just one command. See perldoc CPAN for more.

Re: perl 5.8 upgrade - @INC problem
by castaway (Parson) on Sep 24, 2003 at 07:35 UTC
    Did you build the new perl yourself, or just install a standard pre-built binary? If you run the configure/install yourself, it asks you if it should include the libpaths of any previous versions in the binary, in which case you would see them in perl -V (which lists your current @INC, among other things.)

    If not, you'll have to set the PERL5LIB environment var, as mentioned above.

    C.

Re: perl 5.8 upgrade - @INC problem
by John M. Dlugosz (Monsignor) on Sep 23, 2003 at 18:07 UTC
    Set the PERL5LIB environment variable to point to the old stuff.
Re: perl 5.8 upgrade - @INC problem
by zentara (Cardinal) on Sep 24, 2003 at 15:13 UTC
    What I've done to have separate Perl versions going at once, is to rename the executable. The executable knows where to find it's libs by the way it's compiled. So for instance if I was moving to perl58 from perl56, I would rename the original perl binary to perl56 and then install perl 5.8. When I want to use 5.6, I put #!/usr/bin/perl56 as the shebang line. When I want to use perl 5.8 I use the normal shebang, or I could use #!/usr/bin/perl58. You can even make a symlink @perl to point to which version you want to run as default.