Perl user space
From s5h.net
This is meant as a guide for people who wish to use perl modules in unprivilleged user space.
For this guide we're going to use the CDB_File module as an example. The reasons for this are based on CDB files not being that widely implemented in kitchen sink distros because of the DJB code distribution rules.
Firstly lets get the code and uncompress it
$ tar zxvf CDB_File-0.96.tar.gz CDB_File-0.96/ CDB_File-0.96/ACKNOWLEDGE CDB_File-0.96/bun-x.pl CDB_File-0.96/CDB_File.pm CDB_File-0.96/CDB_File.xs CDB_File-0.96/CHANGES CDB_File-0.96/COPYRIGHT CDB_File-0.96/INSTALL CDB_File-0.96/Makefile.PL CDB_File-0.96/MANIFEST CDB_File-0.96/META.yml CDB_File-0.96/ppport.h CDB_File-0.96/README CDB_File-0.96/t/ CDB_File-0.96/t/01main.t CDB_File-0.96/t/02last.t CDB_File-0.96/typemap $ cd CDB_File-0.96/
We now need to decide where to make our base for perl modules. Lets use $HOME/services/perl, as that's quite a simple location.
$ perl Makefile.PL prefix=$HOME/services/perl Checking if your kit is complete... Looks good Writing Makefile for CDB_File
Lets make the module
$ make cp bun-x.pl blib/lib/bun-x.pl cp CDB_File.pm blib/lib/CDB_File.pm /usr/bin/perl /usr/share/perl/5.10/ExtUtils/xsubpp -typemap /usr/share/perl/5.10/ExtUtils/typemap -typemap typemap CDB_File.xs > CDB_File.xsc && mv CDB_File.xsc CDB_File.c ...
usage
In typical shell environment variables can be defined at the beginning of a command.
Perl has two simple methods of including a module directory, you can use PERL5LIB or use lib. The use lib method is quite useful if you need to decide on the modules location post script execution, where as PERL5LIB is nice as an environment variable.
Sample execution
$ PERL5LIB=~/services/perl/lib/perl perl process_data.pl
If you want to be version independent then you can use the PERLLIB variable instead.
PERLLIB=~/services/perl/lib/perl/5.10.0 perl ~/services/repos/desktop/home/ed/code/mod_cidr/process_data.pl
