perl 模块问题

perl 模块问题
sh-3.2# ./backup.pl 
Can't locate Net/RawIP.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at ./web-scanner.pl line 12.
BEGIN failed--compilation aborted at ./web-scanner.pl line 12.
sh-3.2# perl -MCPAN -e "install Net::RawIP" 
CPAN: Storable loaded ok (v2.19)
Going to read /var/root/.cpan/Metadata
  Database was generated on Mon, 13 Dec 2010 01:34:15 GMT
Net::RawIP is up to date (0.25).

答案1

Perl 查找的位置未安装模块。在运行脚本之前,您可以尝试使用 PERL5LIB 或 PERLLIB 到安装模块的路径。如果您正在运行 bash,则可以将以下内容放入 .bashrc 中:

export PERL5LIB=$PERL5LIB:/opt/local/lib/perl5/site_perl/5.8.9/darwin-2level

或者,您可以添加:

use lib '/opt/local/lib/perl5/site_perl/5.8.9/darwin-2level';

在您的 Perl 脚本中,但如果您有很多 Perl 脚本,这可能不可扩展。

或者,您可以将模块安装在@INC 中的某个目录中。

或者你可以作弊并将目录符号链接到@INC 中的某个目录。

答案2

sh-3.2# find / -name 'RawIP.pm'
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/opt/local/lib/perl5/site_perl/5.8.9/darwin-2level/Net/RawIP.pm
/opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level/RawIP.pm
find: /private/var/folders/xN/xNX35epaFXiyQZnuMC3a3U+++TI/-Tmp-/.truecrypt_aux_mnt1: No such file or directory
/private/var/root/.cpan/build/Net-RawIP-0.25-e5Jys4/blib/lib/Net/RawIP.pm
/private/var/root/.cpan/build/Net-RawIP-0.25-e5Jys4/lib/Net/RawIP.pm
/Users/orly/.Trash/RawIP.pm

相关内容