Net::NetmaskLite (Chapter 3)

This module contains utilities for working with odd-sized netmasks. With it you can easily determine the appropriate broadcast and network addresses for any combination of netmask and IP address. Examine the hostpart(), netpart(), network(), and broadcast() methods to learn the numeric relationships among these parts of the IP address and its netmask.

David Sharnoff's Net::Netmask module, available on CPAN, provides more functionality and is recommended for production work.

 0 package Net::NetmaskLite; 1 # file: Net/NetmaskLite.pm; 2 use strict; 3 use Carp 'croak'; 4 use overload '""'=>netmask; 5 sub new { 6 my $pack = shift; 7 my $mask = shift or croak "Usage: Netmask->new(\$dotted_IP_addr)\n"; 8 my $num = ($mask ...

Get Network Programming with Perl now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.