in reply to Storing and searching sets of IP address ranges

You want Net::CIDR, specifically the cidrlookup function. Pass it an address and a (list of) CIDR blocks and it'll tell you whether the address is in any of the blocks.

If your address range doesn't match a single CIDR block, (eg it's 192.168.32.45 to 192.168.255.255) then you can use the range2cidr function to generate the appropriate list of CIDR blocks.

It should work for both IPv4 and IPv6.