NetAddr::IP is a Perl module that can manage IPv4 and IPv6 addresses and subnets.
SYNOPSIS
use NetAddr::IP qw(
Compact
Coalesce
Zero
Ones
V4mask
V4net
:aton
:old_storable
:old_nth
);
my $ip = new NetAddr::IP 'loopback';
print "The address is ", $ip->addr, " with mask ", $ip->mask, "n" ;
if ($ip->within(new NetAddr::IP "127.0.0.0", "255.0.0.0")) {
print "Is a loopback addressn";
}
# This prints 127.0.0.1/32
print "You can also say $ip...n";
* The following four functions return ipV6 representations of:
:: = Zeros();
FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF: = Ones();
FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask();
::FFFF:FFFF = V4net();
* To accept addresses in the format as returned by inet_aton, invoke the module as:
use NetAddr::IP qw(:aton);
* To enable usage of legacy data files containing NetAddr::IP objects stored using the Storable module.
use NetAddr::IP qw(:old_storable);
* To compact many smaller subnets (see: $me->compact($addr1, $addr2,...)
@compacted_object_list = Compact(@object_list)
* Return a reference to list of NetAddr::IP subnets of $masklen mask length, when $number or more addresses from @list_of_subnets are found to be contained in said subnet.
$arrayref = Coalesce($masklen, $number, @list_of_subnets)
Product's homepage
Requirements:
· Perl