views:

43

answers:

2

I need to test a perl script in a remote server. I tried running it but i got the error

Can't locate Date/Manip.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl . 

So I downloaded the DateManip.pm file and tried to copy it in one of the locations mentioned. But I don't have permission to copy the file in any of these places. Is there a way I can have this *.pm file in my own directory and call it from there or do I HAVE to put it in one of those locations?

+4  A: 

The correct way to do this is install DateManip.pm obviously, however if you cannot for some reason do that, then you can copy the module to any directory you have write permissions to and modify the perl script to include the following:

 use FindBin qw($Bin);
 use lib "$Bin/<relative_path_to_module>";

<relative_path_to_module> is the relative path to the directory where DateManip.pm is located. So if the relative path to the module is ../lib, you would have

use FindBin qw($Bin);
use lib "$Bin/../lib";
ennuikiller
is got the following error - "$BIN" is not exported by the FindBin module.
sfactor
case matters...it should be $Bin not $BIN
ennuikiller
thanks, my bad :).
sfactor
+1  A: 

By default Perl will also look in the current directory (where it is being run) for a module. So the following will work:

./your_program.pl     <= "use DateManip"
./DateManip.pm

If the module was called Date::Manip then the structure would need to be like this:

./your_program.pl     <= "use Date::Manip"
./Date/
./Date/Manip.pm
draegtun