Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > how to include modules in local dir
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 23rd October 19:44
palam_analog
External User
 
Posts: 1
Default how to include modules in local dir



hi,
I am a non-root user and i installed perl modules
in a local dir and using them in perl scripts
using the following methods

use lib "<local_dir_name>";
use <package name>;

is their any way to put local_dir_name in any enviromental variable
such that , no need to put that line in all scripts again & again.

(i got the problem when i moved the modules in local dir to another dir)


Thanks & regards,
palani
  Reply With Quote


 


2 23rd October 19:44
tulan w. hu
External User
 
Posts: 1
Default how to include modules in local dir



PERLLIB or PERL5LIB
  Reply With Quote
3 23rd October 19:45
big and blue
External User
 
Posts: 1
Default how to include modules in local dir


Remember that this then makes this script dependent on your personal
environment. OK if no-one else is going to run them, but...

An alternative (at least on unix-systems), which then allows anyone
to use them, is to write a short interlude shell script to add the
library path(s) on a command line and using this as perl. This still
allows users to override your setting (for testing their own versions),
should they wish to, by setting their own PERL5LIB.

==========
#!/bin/sh

exec /full/path/to/perl -I/full/lib/path/1 -I/full/lib/path/2 ${1+"$@"}
==========

--
-*- Just because I've written it here doesn't -*-
-*- mean that you should, or I do, believe it. -*-
  Reply With Quote
4 23rd October 19:46
palam_analog
External User
 
Posts: 1
Default how to include modules in local dir


hi,

Thankyou for your responses.
i got an another problem.

I am a non-root user. I already have old perl tk version
installed in my system directory. now i downloaded the
new tk version in my local dir.

i added local tk lib dir to PERL5LIB, but perl always
using old tk version in system dir. how to solve it?

"perl -Mlocal_lib perl_file" is working, while running
it from the directory containing local_lib.

but when i put local_lib_path in PERL5LIB , it is not
working.

also when i include local_lib_path in @INC , it is not
working

Thanks & regards,
-palani
  Reply With Quote
5 23rd October 19:46
brian mccauley
External User
 
Posts: 1
Default how to include modules in local dir


palam_analog@yahoo.co.in (Palaniappan) writes:


How did you add local tk lib dir to PERL5LIB?

Find out what you are doing wrong. Stop doing it. Without you
_showing_ us what you are doing we can hardly be more precise than
that


So, I infer, your @INC contains '.'.


How did you put local_lib_path in PERL5LIB?

How it is not working?


How are you including local_lib_path in @INC?

How is it not working?

Please go read the Posting Guidelines - they will explain how to get
the most of out comp.lang.perl.* (and indeed technical newsgroups in
general).

Remember if you find your fingers are typing the words "it is not
working" then stop, delete those words, and replace them with
something that will actually help people to help you.

If you find yourself _describing_ what you did, always pause and ask
yourself "Could I _show_ them what I did?".

Without seeing what you've done I can still offer some random shots in
the dark as to what you did wrong:

Did you perhaps forget to tell your shell to export PERL5LIB?

Did you perhaps modify @INC at run-time and expect the change
propagate backward through time to compile-time? ( use() is a
compile-time operation). (


Suggested further reading:

perldoc lib
perldoc -f use
perldoc perlvar (The section on @INC)

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
  Reply With Quote
Reply


Thread Tools
Display Modes




666