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

Hi,

Newbie question....

I had perl 5.6.0 as part of the RH7.2. I installed 5.8.1, and then installed some new modules. After adding a line in bash_profile (as recommeded by the monks -thank you), I now get the new perl 5.8 when I perl -v, but I can't see any new modules, or any modules for that matter - not even the ones I could see under perl5.6. Where do modules get installed to by default?

I currently have

/usr/bin/perl5.6.0
/usr/local/bin/perl5.8.1

How do I make my new perl 5.8 recognise the any previously installed modules seen under 5.6?

How do I make my new perl recognise newly installed modules?

Is there a reason why the new perl installs by default into a different directory?

Er..that was a bit more than my original question wasn't it - sorry it's the thirst for knowledge you see.

Replies are listed 'Best First'.
Re: where do perl modules install?
by shenme (Priest) on Oct 08, 2003 at 19:51 UTC
    What does "perl -V" tell you?   That is, where does the newer Perl think it should look for modules?

    On my RH7.2 Perl 5.6.1 system the last part of the output reads:

      Compiled at Feb 20 2002 15:01:16
      @INC:
        /usr/lib/perl5/5.6.1/i386-linux
        /usr/lib/perl5/5.6.1
        /usr/lib/perl5/site_perl/5.6.1/i386-linux
        /usr/lib/perl5/site_perl/5.6.1
        /usr/lib/perl5/site_perl/5.6.0/i386-linux
        /usr/lib/perl5/site_perl/5.6.0
        /usr/lib/perl5/site_perl
        .
    
    On another system, RH8.0 with Perl 5.8.0, it reads
      Compiled at Sep  1 2002 23:56:49
      @INC:
        /usr/lib/perl5/5.8.0/i386-linux-thread-multi
        /usr/lib/perl5/5.8.0
        /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
        /usr/lib/perl5/site_perl/5.8.0
        /usr/lib/perl5/site_perl
        /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
        /usr/lib/perl5/vendor_perl/5.8.0
        /usr/lib/perl5/vendor_perl
        .
    
    Check out your directories to verify modules are getting installed where you expect.   Also, a trick I saw here helps me when I'm wondering if I'm 'seeing' the module I just installed.   If you've just installed Acme::WhatZit version 3.14 try
        perl -M'Acme::WhatZit 9'
    That should complain saying it doesn't have version 9, that it only has version 3.14.   That's just one more way to be sure. Of course, if it complains:
        Can't locate Acme/WhatZit.pm in @INC (@INC contains: /usr/.....
    then you know your Perl can't find the module in any of the places it expects them.
Re: where do perl modules install?
by rinceWind (Monsignor) on Oct 08, 2003 at 21:31 UTC
    How do I make my new perl 5.8 recognise the any previously installed modules seen under 5.6?
    There's no reason why it should. Each perl installation has its own directory tree. Unlike some software, the tree is not overwritten when you upgrade.
    Is there a reason why the new perl installs by default into a different directory?
    This has the advantage of allowing you to run both versions in parallel on the same box without them interfering with each other. Also, note that binary XS modules may be incompatible, and may require different builds.

    The install mechanism (make install) picks up the path information from the config with which perl was built, together with other information such as which C compiler to use, compiler and link options, etc.

    As others have said, perl -V will tell you this, and a whole lot more.

    How do I make my new perl recognise newly installed modules?
    It should be doing so, if you are installing them under the new perl.

    As an alternative, you might want to share some modules between both versions. You can do this by installing to your own home grown install directory.

    perl Makefile.PL LIB=/home/me/lib make make test make install
    You need to get this path added to PERL5LIB, which will add it to @LIB without you needing to worry. Add the following to your .bashrc:
    export PERL5LIB=/home/me/lib
    Hope this helps

    --
    I'm Not Just Another Perl Hacker
Re: where do perl modules install?
by Lori713 (Pilgrim) on Oct 08, 2003 at 20:11 UTC
    The code below will give you a listing of all the .pm files located under a certain directory path (all subdirectories too). This will at least let you know what's out there, and where it's located. My code also prints to the screen 'cuz I like to see it doin' sumtin...

    #!/usr/bin/perl5 -w #finds all .pm modules on a Unix box use strict; use File::Find; my $report = "LDT_results.txt"; open MYOUTPUT, "> $report" or die "Can't open $report: $!"; my @directories = ("/usr/local/lib"); my @foundfiles; # Collect all .pm files below each directory in @directories # and put them into @foundfiles find ( sub { push @foundfiles, $File::Find::name if /\.pm$/ }, @directories); #and print them to my file "LDT_results.txt" print "$_\n" for @foundfiles; print MYOUTPUT "$_\n" for @foundfiles; close MYOUTPUT;

    HTH

    Lori

    Update:You need to change the shebang line to point to your version of Perl. For example, I'm migrating my 5.0 scripts to 5.8, so I type perl5_8 on the shebang line instead of perl5 like shown in the example above.

Re: where do perl modules install?
by castaway (Parson) on Oct 09, 2003 at 07:15 UTC
    That all depends on how you installed your new perl version, and how you are installing your modules. From the sound of it, you're just installing RH rpm packages.

    (Is there an rpm of 5.8.1 already?) - If you installed an rpm, then it will be pre-compiled with a default path in which it looks for modules, (see perl -V, as described above.) OTOH, if you built it yourself from source, then you should have had an opportunity to look for previous perl versions, and add their lib paths to the new 5.8.1 binary. If the 5.6.0 lib paths are not in the binary, then you'll need to set PERL5LIB.

    As for modules, same story. If you are just installing module packages, they will land in whichever lib directory they were packaged as. (See rpm -ql <packagename> for the location of the files.) If you are installing modules 'by hand' from CPAN, then it depends which perl you are using to install them, install with 5.8.1, and they land in the 5.8.1 lib path.

    The default for 5.6.1 should be /usr/lib/perl5, and for 5.8.1 /usr/local/lib/perl5.

    C.

      THANKS GUYS! All your help and suggestions helped me to install modules that could be seen by the new perl.