NAME

Net::IP::Identifier::Net - subclass Net::IP to add some functionality

VERSION

version 0.106

SYNOPSIS

use Net::IP::Identifier::Net;

my $net = Net::IP::Identifier::Net->new( IP );

DESCRIPTION

Net::IP::Identifier::Net subclasses Net::IP. IP can be any of the forms accepted by Net::IP.

Stringification is provided, and uses the print method.

Methods

my @cidrs = $net->range_to_cidrs

If $net is a range, it may be specified by a range (like N.N.N.N - M.M.M.M) which may or may not be representable by a single CIDR (N.N.N.N/M). This method returns an array of Net::IP::Identifier::Net objects that span the original range. If $net is representable by a single CIDR, the returned array simply contains the original $net.

my $mask = $net->masked_ip

Returns a string of 1's and 0's that are the starting IP address of $net masked with the inverse of the netmask. This means you get the upper significant bits (the bits that don't change within this netblock). The lower bits are removed.

my $str = $net->print

Override of Net::IP->print, returns a string. For Net::IP::Identifier::Net objects which represent a single IP, the string is a dotted decimal quad (N.N.N.N). If $ip represents a netblock, the string is a CIDR (N.N.N.N/W) if possible, otherwise it is a range (N.N.N.N - N.N.N.N).

Note that Net::IP->print adds '/32' to single IPs, and it shortens CIDRs if possible (like N.N/16).

my $str = $net->compressed

Returns a string. Calls the Net::IP::ip_compress_address() method to shorten IPv6 addresses.

AUTHOR

Reid Augustin <reid@hellosix.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Reid Augustin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.