getting error for modules

D

debraj

Hi all,

I have written a perl script and it uses a module. Now I wish to keep
a separate directory for all my modules. So I read the documents ( for
eg. perldoc perlmod; perldoc perlmodlib; perldoc perlmodinstall) and
finally decided to use the following construct in my script.

use FindBin qw($Bin);
use lib "$Bin/../libs";

Basically I dont want to hard-code the library path. The script should
work it out for itself. Now the problem with the above FindBin is that
it doesnt work if I do from a different directory other than where my
script is kept.

For eg. Say script is /etc/prog/script and lib at /etc/libs and I run
from /etc/prog it works fine. But from /home/ngraving/scripts when I
run it gives error that cant find module in @INC (
/home/ngraving/../libs). Why is this? What is the best method of
solving this and also of getting the library path without coding it? I
know that I can set the PERL5LIB variable but thats not the option I
am looking at. Or do I have to write a sub-routine to solve this ?

Any pointers will be highly helpful.

Thanx
Debhatta
 
J

James Willmore

On 15 Dec 2003 08:44:09 -0800
For eg. Say script is /etc/prog/script and lib at /etc/libs and I
run from /etc/prog it works fine. But from /home/ngraving/scripts
when I run it gives error that cant find module in @INC (
/home/ngraving/../libs). Why is this? What is the best method of
solving this and also of getting the library path without coding it?
I know that I can set the PERL5LIB variable but thats not the option
I am looking at. Or do I have to write a sub-routine to solve this ?

use lib '/home/ngraving/../libs';
-or-

BEGIN {
unshift( @INC, '/home/ngraving/../libs );
}

perldoc perlfaq8
-or-
perldoc -q 'lib'

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
If the aborigine drafted an IQ test, all of Western civilization
would presumably flunk it. -- Stanley Garn
 
J

James Willmore

On 15 Dec 2003 08:44:09 -0800


use lib '/home/ngraving/../libs';
-or-

BEGIN {
unshift( @INC, '/home/ngraving/../libs );
}

You know ..... I gave this directory a second look after posting. Are
you sure about the directory
/home/ngraving/../libs ?
Or did you just clip the path down?
perldoc perlfaq8
-or-
perldoc -q 'lib'

Have a look at the above documents to (dis)prove the soulutions given.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Eat drink and be merry, for tomorrow they may make it illegal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top