| 1 | use Net::Subnet::Count; | ||
| 2 | use IP::Address; | ||
| 3 | |||
| 4 | my $counter | ||
| 5 | = new Net::Subnet::Count ( | ||
| 6 | 'test-00' => new IP::Address("10.0.0.0/9"), | ||
| 7 | 'test-01' => new IP::Address("10.128.0.0/9"), | ||
| 8 | 'test-02' => new IP::Address("161.196.0.0/16"), | ||
| 9 | ); | ||
| 10 | |||
| 11 | $counter->add('test-03', new IP::Address("200.44.0.0/18")); | ||
| 12 | $counter->add('test-03', new IP::Address("200.44.192.0/18")); | ||
| 13 | |||
| 14 | $counter->cache(2); | ||
| 15 | |||
| 16 | my @list; | ||
| 17 | |||
| 18 | foreach my $ip (qw(10.120.0.1 161.196.0.1 10.0.0.5 10.0.0.3 10.0.0.1 | ||
| 19 | 10.128.9.1 10.0.0.3 161.196.66.2 161.196.66.2 161.196.66.5 | ||
| 20 | 200.44.32.10 200.44.200.10)) | ||
| 21 | { | ||
| 22 | my $ipa = new IP::Address($ip); | ||
| 23 | push @list, $ipa; | ||
| 24 | $counter->count($ipa); | ||
| 25 | } | ||
| 26 | |||
| 27 | $counter->count(@list); | ||
| 28 | |||
| 29 | my $r_count = $counter->result; | ||
| 30 | |||
| 31 | foreach my $subnet (sort keys %{$r_count}) { | ||
| 32 | print "Group $subnet has ", $r_count->{$subnet}, | ||
| 33 | " matches\n"; | ||
| 34 | } |