View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Jay Bonci > IP-Unique-0.03 > IP::Unique



Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  


IP::Unique - Store and count unique IPv4 addresses, optimized for large numbers of IPs


        use IP::Unique;
        my $ipun = IP::Unique->new();


        $ipun->unique(); #In this example, 2
        $ipun->total(); #In this example, 3



IP::Unique solves the problem of how to account for uniqueness, given a large number of IP addresses. Since this module is written in C to take advantage of fast integer handling, it performs (in my experience) several times as fast and with (on average), about 1/5th the amount of memory of similar perl solutions.

A traditional way to account for the uniqueness of a list of objects in perl is to use a hash as such:

                $ips->{$_} = 1;
        $unique = int(keys %$ips);

The situation that quickly arises is that perl hashing algorithms perform poorly in regards to memory when they reach millions of objects. Databases are also cumbersome to work with, as 30 million rows are hard to keep distinct (and is a needless waste of time to look up and insert). This is where IP::Unique (hopefully) shines.


IP::Unique is an OO module, so nothing is exported. The module contains the following methods


Version 0.03 - May 11th, 2004

Version 0.02 - May 11th, 2004

Version 0.01 - Feb 19th, 2004


There are several items that can be considered bugs in the module


Jay Bonci, <>


Copyright (C) 2004 by Jay Bonci, Open Source Development Network

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: