Jay Bonci > IP-Unique-0.03 > IP::Unique

Download:
IP-Unique-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

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

SYNOPSIS ^

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

        $ipun->add_ip("127.0.0.1");
        $ipun->add_ip("127.0.0.1");
        $ipun->add_ip("12.34.56.78");

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

        $ipun->compact();

DESCRIPTION ^

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:

        for(@iplist)
        {
                $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.

METHODS

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

CHANGES ^

Version 0.03 - May 11th, 2004

Version 0.02 - May 11th, 2004

Version 0.01 - Feb 19th, 2004

BUGS ^

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

AUTHOR ^

Jay Bonci, <jaybonci@cpan.org>

COPYRIGHT AND LICENSE ^

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: