Reputation: 4021
Assume I downloaded Date::Calc
from http://guest.engelschall.com/~sb/download/.
Now, I have a script, xxx.pl
, which resides in the same directory as the untar-ed "thing" that I downloaded from the link above
When untar-ed, it creates a "Date-Calc-5.6" folder with tons of stuff.
How do I include Date::Calc
in xxx.pl
? (I keep getting "Can't locate Date/Calc.pm in @INC" errors)
Upvotes: 1
Views: 2047
Reputation: 118605
You don't necessarily need to build and install the module. If the module is pure Perl and the build process doesn't create any new code files, you may be able to use a module while it's "still in the box". Assuming that's the case, there's more than one way to do it.
EDIT: It doesn't look like Date::Calc
is pure Perl. You will probably at least have to build it before you can use the module.
Set the $PERL5LIB
environment variable to include the package distribution directory.
Invoke perl
with the -I
switch
perl -I/the/distribution/dir myscript.pl
Put the -I switch on the #! (first) line of the script
#!/usr/bin/perl -I/the/distribution/dir
Use use lib
in the script
use lib qw(/the/distribution/dir);
use The::Package;
Put the distribution directory into the @INC
variable
push @INC, "/the/distribution/dir";
require The::Package;
or
BEGIN {
push @INC, "/the/distribution/dir";
}
use The::Package;
Upvotes: 1
Reputation: 4872
Installing is the preferred method, but if you just want to try it without installing you can do this.
use strict;
use warnings;
use lib '/home/jeremy/Desktop/Date-Calc-5.8/lib';
use Date::Calc;
Please switch out my directory with where yours is unzipped. Also please read about lib.
Upvotes: 1
Reputation: 96937
You first need to install the module.
In your @INC
statement, specify the directory containing your Perl modules. Or use the statement: use lib "path"
to be able to load modules via additional use
statements.
Upvotes: 7
Reputation: 943556
You have to install the module. In most cases, this is best achieved by ignoring the source code tarball and using the cpan utility (on *nix) or the PPM manager (on ActivePerl for Windows).
Upvotes: 2