- or download this
# Process a line and split out the data into variables
my $function = sub {
...
$comment );
if ( is_ipv4($ipaddress) ) {
store_subnet( $ipaddress, $prefix ) if $prefix;
- or download this
# Produce IP subnets from the list of IPs
sub store_subnet {
...
$ip = Socket::inet_ntoa pack "N", $ipn;
$subnets{"$ip,$len"} = { ipn => $ipn, maskn => $maskn };
}
- or download this
# Print it out
print "subnet,prefix\n";
print "$_\n"
for sort { $subnets{$a}{ipn} <=> $subnets{$b}{ipn} }
keys %subnets;
- or download this
sub store_subnet {
my ( $ip, $len, $comment ) = @_;
...
$ip = Socket::inet_ntoa pack "N", $ipn;
$subnets{"$ip,$len,$comment"} = { ipn => $ipn, maskn => $maskn, na
+me => $comment };
}
- or download this
print "subnet,prefix,name\n";
print "$_\n"
for sort { $subnets{$a}{ipn} <=> $subnets{$b}{ipn} }
keys %subnets;