NAME

Net::IP::Identifier::Net - subclass Net::IP to add as_string method and stringification

VERSION

version 0.086

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 as_string 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->as_string

Returns a string. For Net::IP::Identifier::Net objects which represent a single IP, the string is a dotted decimal (N.N.N.N). If $ip represents a netblock, the string is a CIDR (N.N.N.N/W).

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.