perl 无法找到Net/IP.pm

ffvjumwh  于 2023-10-24  发布在  Perl
关注(0)|答案(3)|浏览(135)

我已经成功安装了NetAddr通过这个:cpan -i NetAddr::DNS
现在我试着启动这个基本程序:

use Net::IP;

my $ip = new Net::IP ('193.0.1/24') or die (Net::IP::Error());
print ("IP  : ".$ip->ip()."\n");
print ("Sho : ".$ip->short()."\n");
print ("Bin : ".$ip->binip()."\n");
print ("Int : ".$ip->intip()."\n");
print ("Mask: ".$ip->mask()."\n");
print ("Last: ".$ip->last_ip()."\n");
print ("Len : ".$ip->prefixlen()."\n");
print ("Size: ".$ip->size()."\n");
print ("Type: ".$ip->iptype()."\n");
print ("Rev:  ".$ip->reverse_ip()."\n");

但我得到了:

rr@sd-562 # perl tmp.pl
Can't locate Net/IP.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at tmp.pl line 1.
BEGIN failed--compilation aborted at tmp.pl line 1.
rr@sd-562 # updatedb
rr@sd-562 # locate IP.pm
/root/.cpan/build/NetAddr-IP-4.071-YZOO46/IP.pm
/root/.cpan/build/NetAddr-IP-4.071-YZOO46/blib/lib/NetAddr/IP.pm
/usr/local/lib/perl/5.14.2/NetAddr/IP.pm

我在网上也没找到什么有价值的东西。

lpwwtiir

lpwwtiir1#

Net::IP和NetAddr::IP是不同的模块,它们有不同的名称。

6yoyoihd

6yoyoihd2#

  • IP.pm Can’t locate NetAddr/
  • Netmask.pm Can’t locate Net/
  • DNS.pm Can’t locate Net/
  • Writer.pm Can’t locate XML/
ilmyapht

ilmyapht3#

This article worked for me:ref:https://www.angellight.com/knowledgebase/1581/REQUIRED-module-missing-NetAddr-IP.html
如果您收到错误:无法在@INC中找到NetAddr/IP.pm
然后运行:wget http://www.cpan.org/modules/by-module/NetAddr/NetAddr-IP-4.078.tar.gz tar xvzf NetAddr-IP-4.078.tar.gz cd NetAddr-IP-4.078 perl Makefile.PL make make install

相关问题