English 中文(简体)
为什么网中的“网点”:IP错了吗?
原标题:Why is the netmask in Net::IP set wrong?

I m试图从一个仓库储存到一个数据库里的电离层中获取微薄的仪器。 但是,在用Net处理数据时,我 st:IP。 CPAN模块。 如果我界定了这个网络,那么就不存在问题,但我有手套和面具,不管我如何加入,这个模块总是将网膜打到<<>/32>>>。

我试图这样做:

my $net = "${$query_snmp->{$tablekey}}{ ipRouteMask }/${$query_snmp->{$tablekey}}{ ipRouteDest }";
my $IP = new Net::IP ($net) or die (Net::IP::Error());

但是,所有的IP物体总是用/32创建的,无论我给谁打上了净额。 如果一界定了像<代码>192.168.0.0/20这样的扼杀。 我没有发现任何问题。

我失踪了什么?

Network -> 192.168.65.64/255.255.255.248

IP  : 192.168.65.64
LASTIP  : 192.168.65.64
Sho : 192.168.65.64
Bin : 11000000101010000100000101000000
Int : 3232252224
*** Mask: 255.255.255.255 *** wtf ??
Last: 192.168.65.64
Len : 32
Size: 1
Type: PRIVATE
Rev:  64.65.168.192.in-addr.arpa.
问题回答

http://search.cpan.org/dist/Net-IP/IP.pm”rel=“nofollow”>manual : 净额: IP物体可采用单一IP地址或无等级固定装置制造......

我认为,如果你插入一个有效的网络信使,你会选择指定一个没有班子的网络,为我工作。

#!/usr/bin/perl -w    
use Net::IP;
my $ip = new Net::IP( 112.198.64.0/18 ) or die (Net::IP::Error());
print ("IP  : ".$ip->ip()."
");
print ("Sho : ".$ip->short()."
");
print ("Bin : ".$ip->binip()."
");
print ("Int : ".$ip->intip()."
");
print ("Mask: ".$ip->mask()."
");
print ("Last: ".$ip->last_ip()."
");
print ("Len : ".$ip->prefixlen()."
");
print ("Size: ".$ip->size()."
");
print ("Type: ".$ip->iptype()."
");
print ("Rev:  ".$ip->reverse_ip()."
");

产出:

IP  : 112.198.64.0
Sho : 112.198.64
Bin : 01110000110001100100000000000000
Int : 1892040704
Mask: 255.255.192.0
Last: 112.198.127.255
Len : 18
Size: 16384
Type: PUBLIC
Rev:  64.198.112.in-addr.arpa.

However, if you ve entered "192.168.65.64/255.255.255.248", this is not a format accepted by Net::IP, you ve to use instead "192.68.65.64/29", see this table. In this case it will work correctly:

IP  : 192.168.65.64
Sho : 192.168.65.64
Bin : 11000000101010000100000101000000
Int : 3232252224
Mask: 255.255.255.248
Last: 192.168.65.71
Len : 29
Size: 8
Type: PRIVATE
Rev:  64.65.168.192.in-addr.arpa.

当你使用全部净水体时,由于该格式没有得到承认,它只得到IP,并将给你255.255.255的净额。





相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签