in reply to Matching an IP/subnet amongst a large number of ip subnets

Hello llarochelle,

I used in the past NetAddr::IP that understands cidrs and has the useful within method.

Example fragment:

my $ip = new NetAddr::IP($address_given); my %nets; map { $nets{$_}= new NetAddr::IP($_),} qw( 192.168.0.0/29 10.10.10.0/ +24); foreach my $k (keys %nets){ if ($ip->within($nets{$k})) {

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.