You can add 0.0.0.1 using the binadd method :
#! perl use strict; use warnings; use Net::IP; my $one = Net::IP->new('0.0.0.1'); my $ip1 = Net::IP->new('192.168.0.0/24'); my $ip2 = Net::IP->new('172.168.0.0/16'); my $ip3 = Net::IP->new('10.0.0.0/24'); for my $ip ($ip1, $ip2, $ip3) { print "\nStart IP [", $ip->ip(), "]\n"; print "Start mask [", $ip->prefixlen(), "]\n"; $ip->set($ip->last_ip()); $ip = $ip->binadd($one); print "Next subnet [", $ip->ip(), "]\n"; }
Output:
17:41 >perl 629_SoPW.pl Start IP [192.168.0.0] Start mask [24] Next subnet [192.168.1.0] Start IP [172.168.0.0] Start mask [16] Next subnet [172.169.0.0] Start IP [10.0.0.0] Start mask [24] Next subnet [10.0.1.0] 17:41 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Next subnet
by Athanasius
in thread Next subnet
by ag4ve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |