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

Hi

I'm new to both Perl and linux so I'm struggling a little bit at the moment. I've used Perl ActiveState for windows a little bit and I know how to use the 'use' directive to include modules in Windows because I know where windows installs the Perl packages and if I install a package manually myself i can use the 'use lib' directive like so

use lib 'C:\Perl\site\lib\ensembl-api\ensembl-variation\modules';
However I don't know what to do in Umbuntu. Where does umbuntu put perl modules it installs? I presume they will be put in a path that is part of the Perl5Lib environment variable. Can i still install modules myself manually by simply copying the files to my machine and using the 'use lib' command to point to their location? If so, is there a place where perl modules should be located by convention

many thanks

Replies are listed 'Best First'.
Re: How to use 'use' statement on Umbuntu
by zentara (Cardinal) on Oct 24, 2010 at 22:37 UTC
    The standard place they(distros) put Perl is in /usr/bin/perl. When you are logged into Ubuntu, run this command
    find `perl -e 'print "@INC"'` -name "*.pm"
    All you need to do to use use is USE itelf.
    # for example use CGI;
    You can specify any location you want, by putting this in your ubuntu .bashrc file
    export PERL5LIB=$PERL5LIB:/home/myusername/perl5

    Many of the local homedir installers, will put it in /home/usr/perl5, so making a directory /home/yourusername/perl5 would be a good choice, and add it in your .bashrc file.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      thank you
Re: How to use 'use' statement on Umbuntu
by aquarium (Curate) on Oct 25, 2010 at 00:59 UTC
    another alternative, used by a software system that didn't want to mix up standard install (multiplatform) perls with own modules, was to put all those modules (copy) in own directory structure, and the perl programs always started with "unshift $my_local_modules @INC", thus adding the custom module path to whatever was in effect on server, without messing any system variables etc.
    the hardest line to type correctly is: stty erase ^H
Re: How to use 'use' statement on Ubuntu
by grantm (Parson) on Oct 26, 2010 at 23:16 UTC
    Can i still install modules myself manually by simply copying the files to my machine and using the 'use lib' command to point to their location?

    When you talk about installing modules, are you talking about your own .pm files, or modules from CPAN? If it's your own Perl code then copying the files is fine, but for CPAN modules there are better ways. This is because many modules use compiled C code and rely on other shared libraries, so it's not always as simple as copying files.

    If you have admin access on the Ubuntu server then for most commonly used modules you can use the system package manager to install from the Ubuntu repositories and automatically resolve any dependencies. For example to install the DBD::Pg module you might use the command:

    sudo aptitude install libdbd-pg-perl

    If you have console access you can also use the Synaptic package manager to search and install packages from the GUI.

    To install less commonly used modules that aren't available from the Ubuntu repositories then you should use a CPAN shell like: sudo cpan

    If so, is there a place where perl modules should be located by convention

    When modules are installed using the system package manager they end up under /usr/lib, but you shouldn't manually install any files under there. If you have admin access then your files would typically go under /usr/local/lib but otherwise they should go under your home directory as suggested by zentara.