in reply to Matching an IP/subnet amongst a large number of ip subnets
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*
|
|---|