sub get_ips { my $subnet_specification=shift; # Get the subnet specification. my ($network, $mask)=split(/\//, $subnet_specification); # Break it into a subnet and mask. my @subnet_array=split/\./,$network; # Split the network into individual octets. my $subnet_value=$subnet_array[0]*0x1000000+$subnet_array[1]*0x10000+$subnet_array[2]*0x100+$subnet_array[3]; # $subnet_value now contains a 32-bit value corresponding to the network address given. # Now calculate the top end of the subnet. my $top_address=$subnet_value+(2**(32-$mask)-1); # We now have the first and last addresses required. Produce a list of all addresses in between, in dotted-decimal format. my @return_value; # Holds the array of addresses we are returning for (my $address=$subnet_value; $address<=$top_address; $address++) { my @octets=(int($address/0x1000000)%0x100, int($address/0x10000)%0x100, int($address/0x100)%0x100, $address%0x100); push(@return_value, join(".", @octets)); # Assemble it into a dotted-decimal form and add it to the returned array. } return @return_value; }