The Perl 5 module Net::CIDR::Set represents sets of IP addresses and allows standard set operations (union, intersection, membership test etc) to be performed on them. In spite of the name it can work with sets consisting of arbitrary ranges of IP addresses - not just CIDR blocks. Both IPv4 and IPv6 addresses are handled - but they may not be mixed in the same set.