http://www.perlmonks.org?node_id=867173


in reply to Module for working with IP Addresses and Ranges

IMO the canonical tool for this is Net::CIDR. The interface and documentation is kinda clunky in some ways, but it works, and works very well, for both IPv4 and IPv6.
$ perl -MNet::CIDR -e ' print Net::CIDR::cidrlookup( "192.168.1.130", Net::CIDR::range2cidr("192.168.1.120-192.168.1.141") )' 1 $ perl -MNet::CIDR -e ' print Net::CIDR::cidrlookup( "192.168.1.180", Net::CIDR::range2cidr("192.168.1.120-192.168.1.141") )' 0