Net::Subnet::Count - Count IP Addresses belonging to subnet groups. This is free software. This software comes with NO WARRANTY under the same terms as Perl itself. You use it at your own risk. Follow standard module installation instructions. Please submit feedback to the author, Luis Munoz . Distribution is permitted provided that proper credit is given. This module requires IP::Address which can be found at CPAN. The module documentation below can be seen by typing $perldoc Net::Subnet::Count after properly installing the module. Enjoy. NAME Net::Subnet::Count - Count hosts in named subnets SYNOPSIS use Net::Subnet::Count; use IP::Address; my $counter = new Net::Subnet::Count; $counter->add('subnet-00', new IP::Address("10.0.0.0/24")); $counter->add('other', @array_of_ip_addresses); $counter->add('other', @another_array_of_ip_addresses); $counter->cache(10); $counter->count(new IP:Address("10.0.3.17")); $counter->count(@array_of_ip_addresses); my $r_count = $counter->result; foreach my $subnet (keys %{$r_count}) { print "Subnet $subnet had ", $r_count->{$subnet}, " visits.\n"; } DESCRIPTION This module implements a symplistic way to match individual IP Addresses to subnets. It can be used to, among other things, help analyze HTTPD logs. The following methods are implemented. `->new' Creates a new counter. This method can be called passing as argument a hash where the keys are the name of the subnet group and the values are references to arrays of `IP::Address' objects referencing each specific subnet. This is probably ok for static initializations. `->add' Adds a subnet group. The first parameter is the name of the group being added. If it's a new name, a new entry will be created. Else the given subnets are added to the existing ones, like in the example above. `->count' Verifies if the `IP::Address'es are contained in any of the given subnets. If this is the case, the corresponding totals are updated. `->result' Returns a reference to a hash containing the respective totals for each subnet group. The key to the hash is the subnet name given with `->add', the value is how many `IP::Address' objects have been found to match that subnet group. `->cache' Since in usual applications `IP::Addresses' from the same subnet will tend to be grouped in clusters like in the case of HTTPD logs some caching is attempted to speed things up. The caching consists in storing the last few entries matched in an LRU list which is checked before going through all the stored subnets. This can improve response times if tuned sensibly, however consider that every miss will cause every entry in the cache to be checked twice, one in the cache and one in the normal process so it's important to tune the cache. The default cache size is 5, which can be changed by calling the `- >cache' method as in the example. The old value of the cache size is returned. AUTHOR Luis E. Munoz SEE ALSO perl(1), IP::Address(1).