in reply to ip address calculations

Net::Netmask is what you need. Can do all the IP/network manipulations you want....