top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to find next subnet in perl

+1 vote
266 views

How do I find the next subnet? This should print 192.168.1.0 the second time - it errors:

#!/usr/bin/env perl

use strict;
use warnings;

use Net::IP;

my $ip = Net::IP->new('192.168.0.0/24');

print "Start ip [" . $ip->ip . "]n";
print "start mask [" . $ip->prefixlen . "]n";

$ip->set($ip->last_ip);
$ip++;
$ip->set($ip->ip . "/" . $ip->prefixlen);

print "Start ip [" . $ip->ip . "]n";
print "start mask [" . $ip->prefixlen . "]n";

## ERROR
 % ./t2.pl
Start ip [192.168.0.0]
start mask [24]

Can't call method "ip" on an undefined value at ./t2.pl line 15.

posted May 24, 2013 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

I have tried to install module PDF::FromHTML from cpan but not able to get it.
Please let me know any other module to do the same. please help

...