Perl中的模块查找路径
今天碰到一个问题,Perl中的模块查找路径,问team中的几个总写perl程序的member,居然不清楚。理想中总认为,直接写use AAA::BBB就可以了。嘿嘿~
我们清楚,Java中是如何找到jar包的。那么Perl中是不是也能从“XXXPath“中寻找模块呢?
1. 我修改PathPerl_Home/lib移除
可以正常工作
2. 把Perl_Home/lib中的Getops文件夹移动到别的地方。
通过运行,报错如下:
c:\test\perl>perl test_getopt.pl
Can't locate Getopt/Std.pm in @INC (@INC contains: C:/setup/perl/site/lib C:/setup/perl/lib .) at test_getopt.pl line 5.
BEGIN failed--compilation aborted at test_getopt.pl line 5.
可见Perl寻找的路径了,内置变量@INC,注意当前路径.也在其中。
最后附简单perl程序:
#!c:/setup/perl/bin/perl.exe -w
print "Content-type: text/html\n\n";
print "<html><h1>----------------------</h1></html>\n";
use Getopt::Std;
getopt('de');
print "aaa \n";
页:
[1]