tags:

views:

367

answers:

3

I have a set of intra-dependent Perl projects and would like to use EPIC to work on them. I created one Epic (Eclipse) project for each of my projects and I set dependencies among them using Project|Properties|Project References function. For each project I also set Perl Include Path (@INC) in Project|Properties|Perl Include Path adding paths to the libraries used by this project.

The problem is the @INC setting does not seem to be transitive; if project B references project A, B's @INC does not incorporate A's @INC automatically. In effect I have to manually add paths from A's @INC to B's @INC to make Epic see all necessary Perl libs.

Can it be done automatically?

+1  A: 

Are you aware of the PERL5LIB environment variable, documented in the perlrun manpage?

PERL5LIB

A colon-separated list of directories in which to look for Perl library files before looking in the standard library and the current directory. If PERL5LIB is not defined, PERLLIB is used. When running taint checks (because the script was running setuid or setgid, or the -T switch was used), neither variable is used. The script should instead say

use lib "/my/directory";

In your example, you'd need to set PERL5LIB to the union of @INC values in Project A and Project B.

As noted, if any of the projects enable taint checking (#! /usr/bin/perl -T), then hardcoding is the superior option.

Greg Bacon
Thanks, will try this.
Piotr Dobrogost
+1  A: 

From perlfaq8's answer to How do I add a directory to my include path (@INC) at runtime. You just need to use one of these techniques with EPIC.


How do I add a directory to my include path (@INC) at runtime?

Here are the suggested ways of modifying your include path, including environment variables, run-time switches, and in-code statements:

the PERLLIB environment variable

$ export PERLLIB=/path/to/my/dir
$ perl program.pl

the PERL5LIB environment variable

$ export PERL5LIB=/path/to/my/dir
$ perl program.pl

the perl -Idir command line flag

$ perl -I/path/to/my/dir program.pl

the use lib pragma:

use lib "$ENV{HOME}/myown_perllib";

The last is particularly useful because it knows about machine dependent architectures. The lib.pm pragmatic module was first included with the 5.002 release of Perl.

brian d foy
+1  A: 

If you're migrating to Eclipse and expecting it to use $PERL5LIB, beware that the -T (taint mode) seems to be enabled in EPIC by default. Just set "Perl EPIC"->"Perl executable" to simply "perl" (rather than "perl -T") to get your $PERL5LIB back.

It might be considered better design to define @INC in your Project->Properties, but in our department at least, $PERL5LIB is different from machine-to-machine.

Chad Davis