如何使所有 EPIC 项目都能使用 Perl 的 @INC?
我有一组内部依赖的 Perl 项目,并且想使用 EPIC 来处理它们。我为每个项目创建了一个 Epic (Eclipse) 项目,并使用 Project|Properties|Project References 功能设置它们之间的依赖关系。 对于每个项目,我还在 Project|Properties|Perl Include Path 中设置 Perl Include Path (@INC
),添加该项目使用的库的路径。
问题是 @INC
设置似乎不具有传递性;如果项目 B 引用项目 A,则 B 的 @INC
不会自动合并 A 的 @INC
。实际上,我必须手动添加从 A 的 @INC
到 B 的 @INC
的路径,以使 Epic 看到所有必需的 Perl 库。
可以自动完成吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您正在迁移到 Eclipse 并希望它使用 $PERL5LIB,请注意 -T(污点模式)似乎在 EPIC 中默认启用。只需将“Perl EPIC”->“Perl 可执行文件”设置为“perl”(而不是“perl -T”)即可恢复 $PERL5LIB。
在您的“项目”->“属性”中定义 @INC 可能被认为是更好的设计,但至少在我们部门,$PERL5LIB 因机器而异。
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.
您是否了解 perlrun 手册页?
在您的示例中,您需要将 PERL5LIB 设置为项目 A 和项目 B 中的
@INC
值的并集。如上所述,如果任何项目启用污点检查 (
#!/ usr/bin/perl -T
),那么硬编码是更好的选择。Are you aware of the PERL5LIB environment variable, documented in the perlrun manpage?
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.来自 perlfaq8 的回答 如何在运行时将目录添加到我的包含路径 (@INC)。您只需将其中一种技术与 EPIC 结合使用即可。
如何在运行时将目录添加到我的包含路径 (@INC)?
以下是修改包含路径的建议方法,包括环境变量、运行时开关和代码内语句:
PERLLIB 环境变量
PERL5LIB 环境变量
perl -Idir 命令行标志
use lib pragma:
最后一个是特别的很有用,因为它了解机器相关的体系结构。 lib.pm 实用模块首先包含在 Perl 5.002 版本中。
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
the PERL5LIB environment variable
the perl -Idir command line flag
the use lib pragma:
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.