NetAddr::IP - Manages IPv4 (your traditional IP) addresses and subnets This module is designed as a help for managing (ranges of) IP addresses. It includes efficient implementations for most common tasks done to subnets or ranges of IP addresses, namely verifying if an address is within a subnet, comparing, looping, splitting subnets into longer prefixes, compacting addresses to the shortest prefixes, etc. The general idea, is that you should be able to do use NetAddr::IP; my $ip = new NetAddr::IP $something_vaguely_resembling_a_subnet; and as long as $something_vaguely_resembling_a_subnet holds something that describes a subnet unambiguously, you should receive an object representing such subnet. Currently this includes various flavors of CIDR notation, traditional notation in one, two, three and four dotted octets, hexadecimal, range and subnet notations. Overloading is also used to ease printing and doing simple aritmetic and comparisons on the IP addresses. For instance, you can do things like: use NetAddr::IP; for (my $ip = new NetAddr::IP '10.0.0.1/28'; $ip < $ip->broadcast; $ip ++) { print "$ip\n"; } This will print out something like... 10.0.0.1/28 10.0.0.2/28 10.0.0.3/28 10.0.0.4/28 10.0.0.5/28 (and so on...) ...which is quite useful for generating config files and the such. This works even for huge ranges of IP addresses. This module is entirely written in perl, so you do not need access to a compiler to use it. It has been extensively tested in a variety of platforms. An extensive test suite is provided with the module to verify correct results. The lastest version of this module should be preferred. You can obtain it on http://www.cpan.org/authors/id/L/LU/LUISMUNOZ/ or one of the many CPAN mirrors. Please find a mirror near you to help spread the load. Note that version 3 and above is not completely backwards compatible with version 2. Version 2 was a somewhat unstable work that grew too fast. If you're upgrading from 2.xx, please review your code as some methods no longer exist or have changed. To install, follow the standard CPAN recipe of: $ perl Makefile.PL $ make $ make test If all tests pass, then do $ make install Tests related to address compaction could be too resource-intensive in some environments. If this is your case, you can skip those tests by setting an environment variable before make'ing test. In a bash-like shell, you could use the following example: $ LIGHTERIPTESTS=yes; export LIGHTERIPTESTS The module's documentation can be accessed through POD. After installing the module, you can do $ perldoc NetAddr::IP to access the documentation. Bug reports are welcome. Please do not forget to tell me what version/platform are you running this code on. Providing a small piece of code that shows the bug helps me a lot in sorting it out and possibly in writting more tests for the distribution. Also, this code is intended to be strict and -w safe, so please report cases where warnings are generated so that I can fix them. Report your bugs to me (luismunoz@cpan.org). This software is (c) Luis E. Munoz. It can be used under the terms of the perl artistic license provided that proper credit for the work of the author is preserved in the form of this copyright notice and license for this module.