cancel
Showing results for 
Search instead for 
Did you mean: 

Perl module: local::lib

oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

Perl module: local::lib

Too late for the current platform, but I wonder if Plusnet could include this (or similar) in a future platform. It basically simplifies the process of creating a local non-root perl library and means that users can install modules into their own space using the CPAN shell.
It probably does other things too but that's what I'm aware of. Without having local::lib available globally you need a bit of messing around to "bootstrap" it into perl before perl programs can make use of it. Once its in it sets four environment variables so perl knows where to find modules.

4 REPLIES 4
Prod_Man
Grafter
Posts: 287
Registered: ‎04-08-2007

Re: Perl module: local::lib

Hello there OliverB,
I am not sure if this will work, but I hope this does...
You might be able to use Shell Script to get around this one,
I am not sure if it's technically permitted as I've thought this off the top of my head.
1. LD_LIBRARY_PATH (Requires ALL Libraries needed to be in an accessible directory)

#!/bin/sh
# Set default Library Path and Start Perl
export LD_LIBRARY_PATH='~/cgi-bin/libs'
perl $*

2. LD_PRELOAD - if it's only one module you can get away with

#!/bin/sh
# Set preload to library and Start Perl
export LD_PRELOAD='~/cgi-bin/libs/library.so.x'
perl $*

As for getting that to work with all Perl Scripts ...
I'm not sure at the moment,
I would have thought that index file type & module loading directives in .htaccess would have been the answer.
Hope that helps.
Jim,
oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

Re: Perl module: local::lib

Not sure I get that? Is LD_LIBRARY_PATH the base where Perl gets all its modules?
local::lib sets
MODULEBUILDRC
PERL_MM_OPT
PERL5LIB
PATH
I think PERL5LIB takes priority over the original perl library, but the original path is still in @INC so it falls back correctly.
I get conflicting information on .htaccess but I get the impression it can be used to set environment variables prior to the script loading.
Otherwise I was thinking about forcing local::lib to load using a "use" or "require" command, or maybe a directive in the #! line of the file?
Anyway here's the link to local::lib http://search.cpan.org/~mstrout/local-lib-1.002000/lib/local/lib.pm
and the instructions I was trying to follow:http://www.catalystframework.org/calendar/2007/8
The bit about CPAN doesn't quite work on its own, you need to at least create the folder .cpan and subfolder CPAN and possibly a MyConfig.pm http://sial.org/howto/perl/life-with-cpan/non-root/ after which the lib::local install procedure seems to detect and configure cpan
On another forum someone actually advocated building your own perl binary but I think that's overkill.
Prod_Man
Grafter
Posts: 287
Registered: ‎04-08-2007

Re: Perl module: local::lib

Hello again,
LD_LIBRARY_PATH is an Environment Variable,
which can be used to over-ride where an application looks for Modules when it's executed.
That's the idea of the Script.
The down sides are that:
You then need all the libraries that Perl depends upon (for the version running on the Server).
You need a directory which you can put other libraries in WITH the standard libraries and your extended libraries that you require.
(This takes up your web space, as you don't have permissions for write access to /lib or /usr/lib etc, else it'd be easy).
It also means you need to make something or tell Apache,
to run the script rather than go strait off to Perl without making it load your required libraries.
Hope that explains it a bit better.
Jim,
oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

Re: Perl module: local::lib

Thanks, though I've read if you use PERL5LIB instead then it searches both locations, your own area and the original lib so you get the best of both worlds. The PERL5LIB location is searched first so it can be used to upgrade modules.
I've still got to figure out forcing the environment variable with .htaccess though, can I just use "setenv"?
.htaccess doesn't SEEM to work?
Otherwise do I need a pretend RewriteRule using the E flag?