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
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