Cláudio Valente > CDB_Perl-0.55 > CDB_Perl

Download:
CDB_Perl-0.55.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.55   Source  

NAME ^

CDB_Perl - Perl extension for reading and creating CDB files

SYNOPSIS ^

        ###################
        #### Read a CDB ###
        ###################

        require CDB_Perl::Read;
        my $rcdb = CDB_Perl::Read->new('file.cdb');

        #get all values associated with a key 'key'
        my @values = $rcdb->get_values('key');

        #get the first value (insertion order)
        my $value = $rcdb->get_value('key');
        @values = $rcdb->get_value('key');

        #get the next values, end indicated by undef
        #use when iterating over multiple values of a key
        my $next_value = $rcdb->get_next();

        ####################
        ### Create a CDB ###
        ####################

        require CDB_Perl::Write;
        my $wcdb = CDB_Perl::Write->new('create.cdb');

        #insert key value pairs
        $wcdb->insert('key','value');

        #finish the CDB (automatic in destructor so you don't need to do this)
        $wcdb->finish;

        #####################
        ### tie interface ###
        #####################

        ### Reading

        my %read;
        tie %read, 'CDB_Perl::Read', 'read.cdb';

        #read a key value
        my $val = $read{'key'}; # only first key by insertion order

        #iterate through a CDB (all key/value pairs by insertion order, even multiple ones
        while(my($k,$v) = each(%read)){
                #do something
        }

        ### Creating

        my %write;
        tie %write, 'CDB_Perl::Write', 'write.cdb';

        #store a key/value pair
        $write{'key'} = 'value';

        #write all data, no need to call this, destructor takes care of that
        untie %data;

DESCRIPTION ^

CDB_Perl is a perl only interface to read and create CDB files. CDB stands for Constant Database, a data format created by Dan Berstein.

It's very efficient to read CDB files but creation is somewhat costly. This module is a fall-back option for people with problems using XS modules. See next section for better alternatives.

SEE ALSO ^

CDB_File XS implementation quite faster than this module

The eg directory for some examples on how to use the package

TO DO ^

Improve documentation a lot

AUTHOR ^

Cláudio Valente, <plank@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright 2008 by Cláudio Valente

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.