in reply to path to perl on umbuntu

Welcome to the Monastery

Typing which perl at the command line will tell you where perl lives. Clearly there is a top level usr directory (/usr) otherwise /usr/bin wouldn't exist. Perhaps you should spend some time learning about the linux file system. Searching google is sure to result in some decent tutorials on the subject.

Regarding perl on Ubuntu I'd suggest installing your own version else where. Perl which ships with Ubuntu is used by the OS, I'd strongly advise against messing around with it. It's much safer (and a good learning experience) to install your own version.

See (Help Needed) Uninstall Perl 5.10 and Install 5.8 on Ubuntu 10.04 for reasons not to mess with the system perl and how to install your own version elsewhere on the system.

Update: fixed a couple of typos.

Replies are listed 'Best First'.
Re^2: path to perl on umbuntu
by Anonymous Monk on Oct 27, 2010 at 13:46 UTC

    Thanks for your reply. I will look at downloading and installing another version of Perl. Is there somewhere specific where I should install it? Presumbly I then have to change the line at the top of my perl scripts from #!/usr/bin/perl to this new path?

    Also if I then need to use CPAN to download new perl modules etc, how will CPAN know to put these in my new perl installation path and not the system perl?

      When configuring perl you could tell it to install in /opt/perl:

      ./Configure -des -Dprefix=/opt/perl

      Be sure to read the Readme and INSTALL files prior to installation. Your newly built perl will have it's own version of cpan (in the example above under /opt/perl/bin/cpan), it knows where to put modules.

        I will definitely read the install and readme files prior to installation but I can't find them :) The only perl download I can find for ubuntu 10.10 is this one http://packages.ubuntu.com/maverick/perland it doesn't have an install guide and this is perl 5.10

        Also this list of dependencies refers to some modules I have already installed on the linux machine using apt-get. Does that matter? Can they share these files? For example I have already installed make.

        Many thanks
      Is there somewhere specific where I should install it?
      It does not really matter much, I usually install it as my normal user (not as root) to my home-directory (a subdir of my home that is).

      Presumbly I then have to change the line at the top of my perl scripts from #!/usr/bin/perl to this new path?
      Yes, that's right and you should also set the PATH-enviroment variable (or whatever your shell uses as search-path) up in such a way that your "new" perl is found before the "old", so that you can simply type "perl" on your command prompt and get the new one.

      how will CPAN know to put these in my new perl installation path and not the system perl?
      On installation perl remembers where it is installed and so knows where to install modules (just don't mess with the defaults during installation).

      You later then only have to run the proper perl and everything will be sorted (i.e. wether you run it via perl -MCPAN -e shell or simply via cpan you just have to make sure that your shell is picking up the newly installed perl/cpan).

Re^2: path to perl on umbuntu
by Anonymous Monk on Oct 27, 2010 at 18:10 UTC
    Hi again

    I'd like to understand why I need to install a new version of Perl. I'm not arguing because I don't have any knowledge to argue. I am wondering how, if I install any modules I use in a specific local directory and add that to the Perl5Lib classpath (or whatever its called in Perl, sorry), I could do any damage to anything?

    thanks

      If you add modules to a local/private/personal folder and access them from your scripts by setting PERL5LIB or using use lib then you will not cause any damage to your system or interfere with other programs. This is a good option.

        Ok. I don't know how to configure either cpan or apt-get to install a module to a specific location. (i.e. to a private/local folder). Could you advise me how to do this? I'm currently looking it up but not getting very far

        I've seen this page to configure cpan but i wasn't asked to configure cpan the first time I used it (unless i missed it) and there is no option for where to install moduleshttp://docs.webfaction.com/software/perl.html