use lib qw(/my/path/to/add/);
This adds directories to @INC at compile-time,
so they're valid in subsequent use statements.
Try perldoc lib for more information on this.
The longer answer:
You could do this to add things to @INC:
push @INC, '/my/path/to/add';
because, @INC is just a Perl array, nothing special.
However, use statements are executed at compile
time, not at runtime, so if you simply push onto the array,
@INC won't be changed until runtime, and your use
still won't find what it's looking for.
Pushing things directly onto @INC would work if you're
just doing require, which happens at runtime. But
the short answer is best: just use lib and you'll be happy.
Alan | [reply] [d/l] [select] |
The only way to get @INC changes to be noticed at "compile" time would be to put them in a BEGIN block. But yah, 'use lib' is much preferred.
| [reply] [d/l] [select] |
Installing a module to a user directory is covered in this faq. Basically, when compiling the module yourself, just add PREFIX=/directory to the command line when running Makefile.PL. I've never tried to do this through CPAN.pm, so I'm not sure if you can do it that way. Once you've installed the module, you have a number of options for telling Perl where to look for it. First, like you've heard, is to add the path to the @INC variable via something like push @INC, "/directory";. My preferred method is insteaduse lib "/directory;, which lets Perl check for the module at compile time and probably save you some headaches down the road. There's also an environment variable to do the same thing, but I've never used that, and I'm sure someone else will suggest it ;-). | [reply] [d/l] [select] |
use lib qw(.); # Will add your cwd to @INC
use lib qw(. /path/to/my/home /some/other/dir); # will add those dirs
+to @INC
Command line to do it would be:
perl -I/path/to/include script
Check out:
perldoc lib
perldoc perlrun
Cheers,
KM | [reply] [d/l] [select] |
And of course dont forget the PERL5LIB environmental variable,
which wasnt even mentioned in Camel 2. I have yet to look
at Camel 3.
To some, Perl is an art form. To others it is a religion.
What is it to you?
| [reply] |