in reply to Re^5: Issue in migration of Perl code from 5.6.1 to 5.8.6 (relocatable @INC)
in thread Issue in migration of Perl code from 5.6.1 to 5.8.6

If I end up installing separate Perl, how can I run the code under this version in stead of stock perl? Thanks!
  • Comment on Re^6: Issue in migration of Perl code from 5.6.1 to 5.8.6 (relocatable @INC)

Replies are listed 'Best First'.
Re^7: Issue in migration of Perl code from 5.6.1 to 5.8.6 (relocatable @INC)
by almut (Canon) on Feb 10, 2009 at 17:31 UTC

    Just call the respective perl binary — either directly via its absolute path (typically in the shebang line of your script), or adjust your executable search path (PATH env var) such that the correct perl instance is found first (for when you type "perl somescript.pl" on the command line).

    If things are configured correctly (which is essentially what I was talking about in the last post), the perl binary should find the modules that belong to it — and preferably only those...  which is why it's usually not a good idea to globally set the environment variable PERL5LIB, if you have multiple perls installed (paths in PERL5LIB are being prepended to the configured/hardcoded module search paths in the binary and Config.pm, which could lead to modules being mixed up across different Perl installations).

    An easy way to check if things do work as desired is to simply invoke "perl -V" (capital V), or "/usr/local/perl/5.10/bin/perl -V" (or whatever you have installed) — which prints the perl version and all search paths being used (the latter near the end of the output).

      Hi, Thanks for your reply. I am now trying to setup my own perl and then try installing CPAN modules there. Since we already have perl 5.8.6 installed in a folder called "perl5", I made a copy of that in another folder called "perl5.8". Will this cause any issues? Also, when try to invoke CPAN, it starts initiazing the configuration file in "perl5" folder. How can I start it in teh 5.8 folder? Thanks
        I made a copy of that in another folder called "perl5.8". Will this cause any issues?

        Presumably yes, because - as I said - the original installation directory is hardcoded in the perl binary.

        It's easy to check: just call

        $ /path/to/your/copied/version/in/folder/perl5.8/bin/perl -V

        If that still reports the original @INC paths (which I assume), it won't work.

        Another way to check:

        $ strings /path/to/your/copied/version/in/folder/perl5.8/bin/perl | gr +ep /perl5

        If you see the original installation path among the strings shown, it's hardcoded in the binary...

        (In case you're feeling brave (and all else fails), you could use a binary/hex editor and modify those paths directly in the perl binary. This will only work, however, if the new path is the same length or shorter than the original one. If the new one is shorter, you'll have to put a zero byte (\0) right after the last character of the new path, without modifying the size of the binary (!), i.e. without deleting any left-over garbage after the new string-terminating zero byte.)

      Is there a way to know what modules will need to be installed to get the Perl code working? The Perl script that I am working with uses SOAP::Lite and HTTP::Cookies. When I do perl -MSOAP::Lite -le "print(SOAP::Lite-VERSION)" I get the version numbers for both the above modules. So I assume that they are installed fine. I also installed the LWP Bundle but it still throws the same error. fault_code -1 500 Usage: $h->push_header($field, $val) at /opt/perl5/lib/5.8.6/MatcherClient.pm line 347 Thanks