Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Net::CIDR 0.13

    Download button

    No screenshots available
    Downloads: 176  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Sam Varshavchik | More programs
    Perl Artistic License / FREE
    June 15th, 2010, 08:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Net::CIDR description

    Manipulate IPv4/IPv6 netblocks in CIDR notation

    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

      


    TAGS:

    CIDR notation | IPv4 netblocks | IPv6 netblocks | CIDR | IPv4 | IPv6

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM