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

Dearest Monks

I recently opened a thread about installing Perl on Ubuntu and I've now ended up with a lot more knowledge that when I started that thread thanks to the much appreciated input from you venerable monks. However I am still very confused and need to ask some more question. I thought I would open a new thread to avoid confusion with issues in the previous thread. I hope that is ok

In that thread I was advised to install a local copy of Perl because the Perl that is on Ubuntu is the system Perl. Another suggestion was to use the installed version of Perl but to make sure all of my libraries are installed to a separate folder. I'm actually trying out both approaches for experience and I'm running into problems all over the place :)

I have installed a local version of Perl successfully. The problem I am having with this option is that all of the instruction manuals for all of the things I need to do assume I can use apt-get.
Question 1: Am i right in saying that if I use apt-get it will install modules for use with the system perl and not my local perl? If i want to install modules for local perl I need to use CPAN. This is what I have been doing

The second option as mentioned was to use the system perl but to have all of my libraries in a separate location. The problem I am having here is that I don't know how to configure where apt-get installs a perl module to.
Question 2: How do you configure where apt-get installs perl modules?

Many thanks for your continued help.
  • Comment on Very confused about system perl and local perl

Replies are listed 'Best First'.
Re: Very confused about system perl and local perl
by marto (Cardinal) on Oct 28, 2010 at 14:27 UTC

    "Question 1: Am i right in saying that if I use apt-get it will install modules for use with the system perl and not my local perl? If i want to install modules for local perl I need to use CPAN. This is what I have been doing"

    Correct. Say you installed perl to $HOME/localperl you'd use $HOME/localperl/bin/cpan to install modules for the version of perl you installed rather than the system perl. What problems have you experienced with this?

    Update: Also, you may find registering an account here easier to keep on top of your posts.

    Update 2: answer the second question.

    "The second option as mentioned was to use the system perl but to have all of my libraries in a separate location. The problem I am having here is that I don't know how to configure where apt-get installs a perl module to. Question 2: How do you configure where apt-get installs perl modules?"

    If you install using apg-get to install perl modules you're altering the system perl, as discussed yesterday. This is what you want to avoid either by building your own perl as described yesterday (which you've done in Q1) or consult the CPAN documentation:

    5) "I am not root, how can I install a module in a personal directory?"

    Or see the other advice regarding lib and local::lib

Re: Very confused about system perl and local perl
by Anonymous Monk on Oct 28, 2010 at 14:23 UTC
    Question 1: Am i right in saying that if I use apt-get it will install modules for use with the system perl and not my local perl? If i want to install modules for local perl I need to use CPAN. This is what I have been doing

    That sounds about right

    Question 2: How do you configure where apt-get installs perl modules?

    AFAIK, I think the idea is to use CPAN with MyConfig to install modules in your user directory (or with local::lib)

Re: Very confused about system perl and local perl
by choroba (Cardinal) on Oct 28, 2010 at 14:28 UTC
    1. You are right.
    2. I fear you cannot use apt to install modules to a different path. You have to use CPAN again.
Re: Very confused about system perl and local perl
by scorpio17 (Canon) on Oct 28, 2010 at 15:13 UTC

    If you use 'sudo apt-get install', then the modules get installed by the 'root' user into the system perl area - which is what you want to do if you have multiple users on the machine and they ALL want access to those perl modules.

    If you run cpan using the system perl, you can control where cpan puts the modules. By default, it will put stuff under /usr/lib/perl5/site_perl. The modules that come with the system perl are also under /usr/lib/perl5, but not in site_perl. So you should actually be okay doing it this way. To be safe, you can configure cpan to put things into a different localtion, like "~/lib". Then you have to add a line like "use lib 'path/to/my/lib';" in all your scripts, so it can find your modules.

    The advantage of using apt-get is that the package manager takes care of installing anything else that a module might depend on, and it knows if something gets updated, etc. But the package manager usually does not have the latest greatest versions of every module, and some modules are not in the package manager at all, so a little bit of mix-n-match is probably unavoidable. I personally tend to you apt-get for modules that require external c libraries. It's possible to download/compile/install things like this in your 'home' directory, but it can be a real pain. For pure-perl modules, cpan usually works great.

    The most important step, I think, is that you first make good backups. Just use something like tar&split to backup your entire system to an external USB drive before installing something. That way, if something breaks, you can simply revert back to what you had.

      Ok, that looks as if I 'know' what I am doing as I understand all of that now. The problem I am having with using my local copy of perl is that all of the instructions for things I need to install assume I can just use apt-get, but I can't, so then I have to try and find the appropriate CPAN modules and their dependencies which is a bit trickier when you are a beginner. I dont even know the proper names of what I should be looking for which doesn't help and searching google doesnt help either!
        They're listed in the META.yaml file included in the distribution.
        "finding their dependencies". As ikegami remarked in the other thread about this topic today, the CPAN shell does that for you