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

Hi All, I want to remove $ perl -e 'print @INC' /lib/perl5/5.10.1/i686-linux/usr/local/lib/perl5/5.10.1/usr/local/lib/perl5/site_perl/5.10.1/i686-linux/usr/local/lib/perl5/site_perl/5.10.1. I want to remove all the three directory entries from @INC permanently and add new ones - such as /usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE How do I do it ? Thanks, Onkar
  • Comment on removing paths permanantly from @INC and adding new ones

Replies are listed 'Best First'.
Re: removing paths permanantly from @INC and adding new ones
by keszler (Priest) on Dec 14, 2009 at 05:01 UTC
    Recompile Perl.

    The @INC paths are built into the Perl executable. See Compiling Perl with correct values in @INC for more detail.

    If you're running Perl v5.10.1, why would you want @INC paths to 5.8.5 modules? They are not binary compatible.

      The problem is that I want to run everything with 5.8.5 modules , but there whatever I install goes in 5.10.1 directory - for instance I am installing Proc::Daemon module , which i am expecint to be installed in 5.8.5 directories - mdstest@mds-qa2 Proc-Daemon-0.03$ ls Changes Daemon.pm Makefile.PL MANIFEST README t mdstest@mds-qa2 Proc-Daemon-0.03$ perl Makefile.PL PREFIX=/usr/lib/perl5/5.8.5/i386-linux-thread-multi Checking if your kit is complete... Looks good Writing Makefile for Proc::Daemon mdstest@mds-qa2 Proc-Daemon-0.03$ make cp Daemon.pm blib/lib/Proc/Daemon.pm Manifying blib/man3/Proc::Daemon.3 mdstest@mds-qa2 Proc-Daemon-0.03$ make test PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/00modload.t ..... ok t/01filecreate.t .. ok All tests successful. Files=2, Tests=2, 5 wallclock secs ( 0.01 usr 0.06 sys + 0.02 cusr 0.17 csys = 0.26 CPU) Result: PASS mdstest@mds-qa2 Proc-Daemon-0.03$ sudo make install Appending installation info to /usr/lib/perl5/5.8.5/i386-linux-thread-multi/lib/perl5/5.10.1/i686-linux/perllocal.pod mdstest@mds-qa2 Proc-Daemon-0.03$ see , it is getting installed in /usr/lib/perl5/5.8.5/i386-linux-thread-multi/lib/perl5/5.10.1/i686-linux/perllocal.pod directories What should I do in this case ?
        When you run perl -v does it print
        This is perl, v5.10.1 ...
        or
        This is perl, v5.8.5 ...
        Whichever version it is, the modules you install must match because perl versions 5.8 and 5.10 are not binary compatible, i.e. modules compiled with 5.8 will not work with 5.10 and vice versa (except for pure Perl modules that don't check the version of the perl executable and don't use features of the newer version changed from or not present in the earlier version).

        If you have both versions of perl installed on the same system, they must each have independent @INC paths for their modules. That means you need to install module X twice, once for each version.

        The PREFIX= parameter to Makefile.PL is intended for use when you do not have root privileges and must install modules somewhere other than the standard /usr/lib (or whatever default). It will not - as you've seen - enable you to put v5.10 modules in v5.8 directories.

        By the way, your posts will be far more readable if you add <code> tags around things like commands and output. If said <code> is lengthy you should also use <readmore> tags. Example:

        A reply falls below the community's threshold of quality. You may see it by logging in.
        Have you tried using the perl5.8.5 binary when you built the module?
        /usr/bin/perl5.8.5 Makefile.PL make make test make install

        print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
Re: removing paths permanantly from @INC and adding new ones
by ikegami (Patriarch) on Dec 14, 2009 at 06:17 UTC

    The files in /usr/lib/perl5/5.8.5/i386-linux-thread-multi/... wouldn't be compatible with 5.10.1. Binary modules for one major version of Perl (5.8) can't be used by a different major version of Perl (5.10).

    If you want to test your modules with Perl 5.8.5, why don't you install Perl 5.8.5? You can have multiple version of Perl on the same machine. There's no need to remove Perl 5.10.1.