CDB_Perl - Perl extension for reading and creating CDB files


CDB_Perl documentation  | view source Contained in the CDB_Perl distribution.

Index


NAME

Top

CDB_Perl - Perl extension for reading and creating CDB files

SYNOPSIS

Top

	###################
	#### 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

Top

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

Top

CDB_File XS implementation quite faster than this module

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

TO DO

Top

Improve documentation a lot

AUTHOR

Top

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

COPYRIGHT AND LICENSE

Top


CDB_Perl documentation  | view source Contained in the CDB_Perl distribution.