NetAddr::IP contains complex  operations on nets, net ranges , etc... all implemented in perl.