You may want to look at Net::CIDR and/or Net::Netmask.
In reply to Re: Has this been written before by tirwhan in thread Has this been written before by mrbbq