Net::CIDR is a Perl module that contains functions that manipulate lists of IP netblocks expressed in CIDR notation. The Net::CIDR functions handle both IPv4 and IPv6 addresses.
@cidr_list=Net::CIDR::range2cidr(@range_list);
Each element in the @range_list is a string "start-finish", where "start" is the first IP address and "finish" is the last IP address. range2cidr() converts each range into an equivalent CIDR netblock. It returns a list of netblocks except in the case where it is given only one parameter and is called in scalar context.
SYNOPSIS
use Net::CIDR;
use Net::CIDR ':all';
print join("\n",
Net::CIDR::range2cidr("192.68.0.0-192.68.255.255",
"10.0.0.0-10.3.255.255"))
. "\n";
#
# Output from above:
#
# 192.68.0.0/16
# 10.0.0.0/14
print join("\n",
Net::CIDR::range2cidr(
"dead:beef::-dead:beef:ffff:ffff:ffff:ffff:ffff:ffff"))
. "\n";
#
# Output from above:
#
# dead:beef::/32
print join("\n",
Net::CIDR::range2cidr("192.68.1.0-192.68.2.255"))
. "\n";
#
# Output from above:
#
# 192.68.1.0/24
# 192.68.2.0/24
print join("\n", Net::CIDR::cidr2range("192.68.0.0/16")) . "\n";
#
# Output from above:
#
# 192.68.0.0-192.68.255.255
print join("\n", Net::CIDR::cidr2range("dead::beef::/46")) . "\n";
#
# Output from above:
#
# dead:beef::-dead:beef:3:ffff:ffff:ffff:ffff:ffff
@list=("192.68.0.0/24");
@list=Net::CIDR::cidradd("192.68.1.0-192.68.1.255", @list);
print join("\n", @list) . "\n";
#
# Output from above:
#
# 192.68.0.0/23
print join("\n", Net::CIDR::cidr2octets("192.68.0.0/22")) . "\n";
#
# Output from above:
#
# 192.68.0
# 192.68.1
# 192.68.2
# 192.68.3
print join("\n", Net::CIDR::cidr2octets("dead::beef::/46")) . "\n";
#
# Output from above:
#
# dead:beef:0000
# dead:beef:0001
# dead:beef:0002
# dead:beef:0003
@list=("192.68.0.0/24");
print Net::CIDR::cidrlookup("192.68.0.12", @list);
#
# Output from above:
#
# 1
@list = Net::CIDR::addr2cidr("192.68.0.31");
print join("\n", @list);
#
# Output from above:
#
# 192.68.0.31/32
# 192.68.0.30/31
# 192.68.0.28/30
# 192.68.0.24/29
# 192.68.0.16/28
# 192.68.0.0/27
# 192.68.0.0/26
# 192.68.0.0/25
# 192.68.0.0/24
# 192.68.0.0/23
# [and so on]
print Net::CIDR::addrandmask2cidr("195.149.50.61", "255.255.255.248")."\n";
#
# Output from above:
#
# 195.149.50.56/29
Product's homepage
Requirements:
· Perl