[plug] Dynamic Perl Library Pathing...

Trevor Phillips T.Phillips at murdoch.edu.au
Mon Oct 14 14:53:53 WST 2002


I'm trying to distribute a few perl scripts with dependent custom libraries 
which are installed relative to the script, and NOT within the main Perl lib 
heirarchy. Normally, I'd hard-code the path into a "use lib" call before 
use-ing the other libraries, but if I'm going to be putting this on several 
systems, and letting others at it, I'd rather not have to manually edit the 
scripts all the time.

I've tried this:
   $_=$0; s/[^\/]*$//;
   use lib $_;
... but it needs the value at compile time.

I've tried this:
   $_=$0; s/[^\/]*$//;
   eval "use lib $_" if ($_);
... but then none of the modules can be found. 

I could possibly get it working by eval-ing all use's, but that seems to be 
getting messier and messier.

Does anyone know of any other clean-ish techniques of doing what I want?

-- 
. Trevor Phillips             -           http://jurai.murdoch.edu.au/ . 
: Web Technical Administrator     -          T.Phillips at murdoch.edu.au : 
| IT Services                        -              Murdoch University | 
 >--------------------------------------------------------------------<
| On nights such as this, evil deeds are done. And good deeds, of     /
| course. But mostly evil, on the whole.                             /
 \      -- (Terry Pratchett, Wyrd Sisters)                          /



More information about the plug mailing list