in reply to How many addresses between two IPs?
Cool. I haven't had a look at NetAddr::IP but I had to some similar calculation in one of the NMS programs where we don't want to use non-core modules (in this case to determine if an IP was in a specified network.) In case one is in a similar position of needing to do this calculation and not able to install the module, the code can boil down to:
but, yes, you are probably better off using the module if you can.
my ($ip,$number ) = @_;
my $ip_i = ip_to_int($ip);
$ip_i += $number;
return inet_ntoa(pack('N', $ip_i));
my ( $ip ) = @_;
my $ip_n = inet_aton($ip);
my $ip_i = unpack('N', $ip_n);