Manual Pages for UNIX Darwin command on man BerkeleyDB
MyWebUniversity

Manual Pages for UNIX Darwin command on man BerkeleyDB

BerkeleyDB(3) User Contributed Perl Documentation BerkeleyDB(3)

NAME

BerkeleyDB - Perl extension for Berkeley DB version 2, 3 or 4

SYNOPSIS

use BerkeleyDB;

$env = new BerkeleyDB::Env [OPTIONS] ;

$db = tie %hash, 'BerkeleyDB::Hash', [OPTIONS] ;

$db = new BerkeleyDB::Hash [OPTIONS] ;

$db = tie %hash, 'BerkeleyDB::Btree', [OPTIONS] ;

$db = new BerkeleyDB::Btree [OPTIONS] ;

$db = tie @array, 'BerkeleyDB::Recno', [OPTIONS] ;

$db = new BerkeleyDB::Recno [OPTIONS] ;

$db = tie @array, 'BerkeleyDB::Queue', [OPTIONS] ;

$db = new BerkeleyDB::Queue [OPTIONS] ;

$db = new BerkeleyDB::Unknown [OPTIONS] ;

$status = BerkeleyDB::dbremove [OPTIONS]

$status = BerkeleyDB::dbrename [OPTIONS]

$status = BerkeleyDB::dbverify [OPTIONS]

$hash{$key} = $value ;

$value = $hash{$key} ;

each %hash ;

keys %hash ;

values %hash ;

$status = $db->dbget()

$status = $db->dbput() ;

$status = $db->dbdel() ;

$status = $db->dbsync() ;

$status = $db->dbclose() ;

$status = $db->dbpget()

$hashref = $db->dbstat() ;

$status = $db->dbkeyrange();

$type = $db->type() ;

$status = $db->status() ;

$boolean = $db->byteswapped() ;

$status = $db->truncate($count) ;

$status = $db->compact($start, $stop, $cdata, $flags, $end);

$bool = $env->cdsenabled();

$bool = $db->cdsenabled();

$lock = $db->cdslock();

$lock->cdsunlock();

($flag, $oldoffset, $oldlength) = $db->partialset($offset, $length) ;

($flag, $oldoffset, $oldlength) = $db->partialclear() ;

$cursor = $db->dbcursor([$flags]) ;

$newcursor = $cursor->cdup([$flags]);

$status = $cursor->cget() ;

$status = $cursor->cput() ;

$status = $cursor->cdel() ;

$status = $cursor->ccount() ;

$status = $cursor->cpget() ;

$status = $cursor->status() ;

$status = $cursor->cclose() ;

$cursor = $db->dbjoin() ;

$status = $cursor->cget() ;

$status = $cursor->cclose() ;

$status = $env->txncheckpoint()

$hashref = $env->txnstat()

$status = $env->setmutexlocks()

$status = $env->setflags()

$txn = $env->txnbegin() ;

$db->Txn($txn);

$txn->Txn($db1, $db2,...);

$status = $txn->txnprepare()

$status = $txn->txncommit()

$status = $txn->txnabort()

$status = $txn->txnid()

$status = $txn->txndiscard()

$status = $env->setlgdir();

$status = $env->setlgbsize();

$status = $env->setlgmax();

$status = $env->setdatadir() ;

$status = $env->settmpdir() ;

$status = $env->setverbose() ;

$dbenvptr = $env->DBENV() ;

$BerkeleyDB::Error

$BerkeleyDB::dbversion

# DBM Filters

$oldfilter = $db->filterstorekey ( sub { ... } ) ;

$oldfilter = $db->filterstorevalue( sub { ... } ) ;

$oldfilter = $db->filterfetchkey ( sub { ... } ) ;

$oldfilter = $db->filterfetchvalue( sub { ... } ) ;

# deprecated, but supported

$txnmgr = $env->TxnMgr();

$status = $txnmgr->txncheckpoint()

$hashref = $txnmgr->txnstat()

$txn = $txnmgr->txnbegin() ;

DESCRIPTION

NNOOTTEE:: TThhiiss ddooccuummeenntt iiss ssttiillll uunnddeerr ccoonnssttrruuccttiioonn.. EExxppeecctt iitt ttoo bbee iinnccoommpplleettee iinn ppllaacceess.. This Perl module provides an interface to most of the functionality available in Berkeley DB versions 2, 3 and 4. In general it is safe to assume that the interface provided here to be identical to the Berkeley DB interface. The main changes have been to make the Berkeley DB API work in a Perl way. Note that if you are using Berkeley DB 2.x, the new features available in Berkeley DB 3.x or DB 4.x are not available via this module. The reader is expected to be familiar with the Berkeley DB documentation. Where the interface provided here is identical to the Berkeley DB library and the... TODO The ddbbaappppiinniitt, ddbbccuurrssoorr, ddbbooppeenn and ddbbttxxnn man pages are particularly relevant. The interface to Berkeley DB is implemented with a number of Perl classes.

The BerkeleyDB::Env Class

The BBeerrkkeelleeyyDDBB::::EEnnvv class provides an interface to the Berkeley DB

function ddbbaappppiinniitt in Berkeley DB 2.x or ddbbeennvvccrreeaattee and DDBBEENNVV->>ooppeenn

in Berkeley DB 3.x/4.x. Its purpose is to initialise a number of sub-

systems that can then be used in a consistent way in all the databases you make use of in the environment. If you don't intend using transactions, locking or logging, then you shouldn't need to make use of BBeerrkkeelleeyyDDBB::::EEnnvv. Note that an environment consists of a number of files that Berkeley DB manages behind the scenes for you. When you first use an environment, it needs to be explicitly created. This is done by including "DBCREATE" with the "Flags" parameter, described below. SSyynnooppssiiss

$env = new BerkeleyDB::Env

[ -Home => $path, ]

[ -Server => $name, ]

[ -CacheSize => $number, ]

[ -Config => { name => value, name => value }, ]

[ -ErrFile => filename, ]

[ -ErrPrefix => "string", ]

[ -Flags => number, ]

[ -SetFlags => bitmask, ]

[ -LockDetect => number, ]

[ -SharedMemKey => number, ]

[ -Verbose => boolean, ]

[ -Encrypt => { Password => "string",

Flags => number }, ]

All the parameters to the BerkeleyDB::Env constructor are optional.

-Home

If present, this parameter should point to an existing directory.

Any files that aren't specified with an absolute path in the sub-

systems that are initialised by the BerkeleyDB::Env class will be

assumed to live in the HHoommee directory. For example, in the code fragment below the database "fred.db" will be opened in the directory "/home/databases" because it was specified as a relative path, but "joe.db" will be opened in "/other" because it was part of an absolute path.

$env = new BerkeleyDB::Env

-Home => "/home/databases"

...

$db1 = new BerkeleyDB::Hash

-Filename = "fred.db",

-Env => $env

...

$db2 = new BerkeleyDB::Hash

-Filename = "/other/joe.db",

-Env => $env

...

-Server

If present, this parameter should be the hostname of a server that is running the Berkeley DB RPC server. All databases will be accessed via the RPC server.

-Encrypt

If present, this parameter will enable encryption of all data before it is written to the database. This parameters must be given a hash reference. The format is shown below.

-Encrypt => { -Password => "abc", Flags => DBENCRYPTAES }

Valid values for the Flags are 0 or "DBENCRYPTAES". This option requires Berkeley DB 4.1 or better.

-Cachesize

If present, this parameter sets the size of the environments shared memory buffer pool.

-SharedMemKey

If present, this parameter sets the base segment ID for the shared memory region used by Berkeley DB. This option requires Berkeley DB 3.1 or better.

Use "$env->getshmkey($id)" to find out the base segment ID used

once the environment is open.

-Config

This is a variation on the "-Home" parameter, but it allows finer

control of where specific types of files will be stored. The parameter expects a reference to a hash. Valid keys are: DDBBDDAATTAADDIIRR, DDBBLLOOGGDDIIRR and DDBBTTMMPPDDIIRR The code below shows an example of how it can be used.

$env = new BerkeleyDB::Env

-Config => { DBDATADIR => "/home/databases",

DBLOGDIR => "/home/logs", DBTMPDIR => "/home/tmp" } ...

-ErrFile

Expects a filename or filenhandle. Any errors generated internally by Berkeley DB will be logged to this file. A useful debug setting is to open environments with either

-ErrFile => *STDOUT

or

-ErrFile => *STDERR

-ErrPrefix

Allows a prefix to be added to the error messages before they are

sent to -EErrrrFFiillee.

-Flags

The FFllaaggss parameter specifies both which sub-systems to

initialise, as well as a number of environment-wide options. See

the Berkeley DB documentation for more details of these options. Any of the following can be specified by OR'ing them: DDBBCCRREEAATTEE If any of the files specified do not already exist, create them. DDBBIINNIITTCCDDBB Initialise the Concurrent Access Methods DDBBIINNIITTLLOOCCKK

Initialise the Locking sub-system.

DDBBIINNIITTLLOOGG

Initialise the Logging sub-system.

DDBBIINNIITTMMPPOOOOLL Initialise the ... DDBBIINNIITTTTXXNN Initialise the ... DDBBMMPPOOOOLLPPRRIIVVAATTEE Initialise the ... DDBBIINNIITTMMPPOOOOLL is also specified. Initialise the ... DDBBNNOOMMMMAAPP Initialise the ... DDBBRREECCOOVVEERR DDBBRREECCOOVVEERRFFAATTAALL DDBBTTHHRREEAADD DDBBTTXXNNNNOOSSYYNNCC DDBBUUSSEEEENNVVIIRROONN DDBBUUSSEEEENNVVIIRROONNRROOOOTT

-SetFlags

Calls ENV->setflags with the supplied bitmask. Use this when you

need to make use of DBENV->setflags before DBENV->open is

called. Only valid when Berkeley DB 3.x or better is used.

-LockDetect

Specifies what to do when a lock conflict occurs. The value should be one of DDBBLLOOCCKKDDEEFFAAUULLTT DDBBLLOOCCKKOOLLDDEESSTT DDBBLLOOCCKKRRAANNDDOOMM DDBBLLOOCCKKYYOOUUNNGGEESSTT

-Verbose

Add extra debugging information to the messages sent to -EErrrrFFiillee.

Methods The environment class has the following methods:

$env->errPrefix("string") ;

This method is identical to the -EErrrrPPrreeffiixx flag. It allows the

error prefix string to be changed dynamically.

$env->setflags(bitmask, 1|0);

$txn = $env->TxnMgr()

Constructor for creating a TTxxnnMMggrr object. See "TRANSACTIONS" for more details of using transactions. This method is deprecated. Access the transaction methods using the ttxxnn methods below from the environment object directly.

$env->txnbegin()

TODO

$env->txnstat()

TODO

$env->txncheckpoint()

TODO

$env->status()

Returns the status of the last BerkeleyDB::Env method.

$env->DBENV()

Returns a pointer to the underlying DBENV data structure that Berkeley DB uses.

$env->getshmkey($id)

Writes the base segment ID for the shared memory region used by

the Berkeley DB environment into $id. Returns 0 on success.

This option requires Berkeley DB 4.2 or better.

Use the "-SharedMemKey" option when opening the environemt to set

the base segment ID.

$env->status()

Returns the status of the last BerkeleyDB::Env method.

EExxaammpplleess TODO. GGlloobbaall CCllaasssseess

$status = BerkeleyDB::dbremove [OPTIONS]

$status = BerkeleyDB::dbrename [OPTIONS]

$status = BerkeleyDB::dbverify [OPTIONS]

TTHHEE DDAATTAABBAASSEE CCLLAASSSSEESS BBeerrkkeelleeyyDDBB supports the following database formats: BBeerrkkeelleeyyDDBB::::HHaasshh This database type allows arbitrary key/value pairs to be stored in data files. This is equivalent to the functionality provided by other hashing packages like DBM, NDBM, ODBM, GDBM, and SDBM. Remember though, the files created using BBeerrkkeelleeyyDDBB::::HHaasshh are not compatible with any of the other packages mentioned. A default hashing algorithm, which will be adequate for most

applications, is built into BerkeleyDB. If you do need to use your

own hashing algorithm it is possible to write your own in Perl and have BBeerrkkeelleeyyDDBB use it instead. BBeerrkkeelleeyyDDBB::::BBttrreeee The Btree format allows arbitrary key/value pairs to be stored in a B+tree. As with the BBeerrkkeelleeyyDDBB::::HHaasshh format, it is possible to provide a user defined Perl routine to perform the comparison of keys. By default, though, the keys are stored in lexical order. BBeerrkkeelleeyyDDBB::::RReeccnnoo TODO. BBeerrkkeelleeyyDDBB::::QQuueeuuee TODO. BBeerrkkeelleeyyDDBB::::UUnnkknnoowwnn This isn't a database format at all. It is used when you want to open an existing Berkeley DB database without having to know what type is it. Each of the database formats described above is accessed via a corresponding BBeerrkkeelleeyyDDBB class. These will be described in turn in the next sections. BBeerrkkeelleeyyDDBB::::HHaasshh Equivalent to calling ddbbooppeenn with type DDBBHHAASSHH in Berkeley DB 2.x and

calling ddbbccrreeaattee followed by DDBB->>ooppeenn with type DDBBHHAASSHH in Berkeley DB

3.x or greater. Two forms of constructor are supported:

$db = new BerkeleyDB::Hash

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Hash specific

[ -Ffactor => number,]

[ -Nelem => number,]

[ -Hash => code reference,]

[ -DupCompare => code reference,]

and this

[$db =] tie %hash, 'BerkeleyDB::Hash',

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Hash specific

[ -Ffactor => number,]

[ -Nelem => number,]

[ -Hash => code reference,]

[ -DupCompare => code reference,]

When the "tie" interface is used, reading from and writing to the database is achieved via the tied hash. In this case the database operates like a Perl associative array that happens to be stored on disk.

In addition to the high-level tied hash interface, it is possible to

make use of the underlying methods provided by Berkeley DB Options

In addition to the standard set of options (see "COMMON OPTIONS")

BBeerrkkeelleeyyDDBB::::HHaasshh supports these options:

-Property

Used to specify extra flags when opening a database. The following flags may be specified by bitwise OR'ing together one or more of the following values: DDBBDDUUPP When creating a new database, this flag enables the storing of duplicate keys in the database. If DDBBDDUUPPSSOORRTT is not specified as well, the duplicates are stored in the order they are created in the database. DDBBDDUUPPSSOORRTT Enables the sorting of duplicate keys in the database. Ignored if DDBBDDUUPP isn't also specified.

-Ffactor

-Nelem

See the Berkeley DB documentation for details of these options.

-Hash

Allows you to provide a user defined hash function. If not specified, a default hash function is used. Here is a template for

a user-defined hash function

sub hash {

my ($data) = shift ;

...

# return the hash value for $data

return $hash ;

}

tie %h, "BerkeleyDB::Hash",

-Filename => $filename,

-Hash => \&hash,

... See "" for an example.

-DupCompare

Used in conjunction with the DDBBDDUUPPOOSSRRTT flag. sub compare {

my ($key, $key2) = @ ;

...

# return 0 if $key1 eq $key2

# -1 if $key1 lt $key2

# 1 if $key1 gt $key2

return (-1 , 0 or 1) ;

}

tie %h, "BerkeleyDB::Hash",

-Filename => $filename,

-Property => DBDUP|DBDUPSORT,

-DupCompare => \&compare,

... Methods BBeerrkkeelleeyyDDBB::::HHaasshh only supports the standard database methods. See "COMMON DATABASE METHODS". AA SSiimmppllee TTiieedd HHaasshh EExxaammppllee use strict ;

use BerkeleyDB ;

use vars qw( %h $k $v ) ;

my $filename = "fruit" ;

unlink $filename ;

tie %h, "BerkeleyDB::Hash",

-Filename => $filename,

-Flags => DBCREATE

or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;

# Add a few key/value pairs to the file

$h{"apple"} = "red" ;

$h{"orange"} = "orange" ;

$h{"banana"} = "yellow" ;

$h{"tomato"} = "red" ;

# Check for existence of a key

print "Banana Exists\n\n" if $h{"banana"} ;

# Delete a key/value pair.

delete $h{"apple"} ;

# print the contents of the file

while (($k, $v) = each %h)

{ print "$k -> $v\n" }

untie %h ;

here is the output: Banana Exists

orange -> orange

tomato -> red

banana -> yellow

Note that the like ordinary associative arrays, the order of the keys retrieved from a Hash database are in an apparently random order. AAnnootthheerr SSiimmppllee HHaasshh EExxaammppllee Do the same as the previous example but not using tie. use strict ;

use BerkeleyDB ;

my $filename = "fruit" ;

unlink $filename ;

my $db = new BerkeleyDB::Hash

-Filename => $filename,

-Flags => DBCREATE

or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;

# Add a few key/value pairs to the file

$db->dbput("apple", "red") ;

$db->dbput("orange", "orange") ;

$db->dbput("banana", "yellow") ;

$db->dbput("tomato", "red") ;

# Check for existence of a key

print "Banana Exists\n\n" if $db->dbget("banana", $v) == 0;

# Delete a key/value pair.

$db->dbdel("apple") ;

# print the contents of the file

my ($k, $v) = ("", "") ;

my $cursor = $db->dbcursor() ;

while ($cursor->cget($k, $v, DBNEXT) == 0)

{ print "$k -> $v\n" }

undef $cursor ;

undef $db ;

DDuupplliiccaattee kkeeyyss The code below is a variation on the examples above. This time the hash has been inverted. The key this time is colour and the value is the fruit name. The DDBBDDUUPP flag has been specified to allow duplicates. use strict ;

use BerkeleyDB ;

my $filename = "fruit" ;

unlink $filename ;

my $db = new BerkeleyDB::Hash

-Filename => $filename,

-Flags => DBCREATE,

-Property => DBDUP

or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;

# Add a few key/value pairs to the file

$db->dbput("red", "apple") ;

$db->dbput("orange", "orange") ;

$db->dbput("green", "banana") ;

$db->dbput("yellow", "banana") ;

$db->dbput("red", "tomato") ;

$db->dbput("green", "apple") ;

# print the contents of the file

my ($k, $v) = ("", "") ;

my $cursor = $db->dbcursor() ;

while ($cursor->cget($k, $v, DBNEXT) == 0)

{ print "$k -> $v\n" }

undef $cursor ;

undef $db ;

here is the output:

orange -> orange

yellow -> banana

red -> apple

red -> tomato

green -> banana

green -> apple

SSoorrttiinngg DDuupplliiccaattee KKeeyyss In the previous example, when there were duplicate keys, the values are sorted in the order they are stored in. The code below is identical to the previous example except the DDBBDDUUPPSSOORRTT flag is specified. use strict ;

use BerkeleyDB ;

my $filename = "fruit" ;

unlink $filename ;

my $db = new BerkeleyDB::Hash

-Filename => $filename,

-Flags => DBCREATE,

-Property => DBDUP | DBDUPSORT

or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;

# Add a few key/value pairs to the file

$db->dbput("red", "apple") ;

$db->dbput("orange", "orange") ;

$db->dbput("green", "banana") ;

$db->dbput("yellow", "banana") ;

$db->dbput("red", "tomato") ;

$db->dbput("green", "apple") ;

# print the contents of the file

my ($k, $v) = ("", "") ;

my $cursor = $db->dbcursor() ;

while ($cursor->cget($k, $v, DBNEXT) == 0)

{ print "$k -> $v\n" }

undef $cursor ;

undef $db ;

Notice that in the output below the duplicate values are sorted.

orange -> orange

yellow -> banana

red -> apple

red -> tomato

green -> apple

green -> banana

CCuussttoomm SSoorrttiinngg DDuupplliiccaattee KKeeyyss Another variation TODO CChhaannggiinngg tthhee hhaasshh TODO UUssiinngg ddbbssttaatt TODO BBeerrkkeelleeyyDDBB::::BBttrreeee Equivalent to calling ddbbooppeenn with type DDBBBBTTRREEEE in Berkeley DB 2.x and

calling ddbbccrreeaattee followed by DDBB->>ooppeenn with type DDBBBBTTRREEEE in Berkeley

DB 3.x or greater. Two forms of constructor are supported:

$db = new BerkeleyDB::Btree

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Btree specific

[ -Minkey => number,]

[ -Compare => code reference,]

[ -DupCompare => code reference,]

[ -Prefix => code reference,]

and this

[$db =] tie %hash, 'BerkeleyDB::Btree',

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Btree specific

[ -Minkey => number,]

[ -Compare => code reference,]

[ -DupCompare => code reference,]

[ -Prefix => code reference,]

Options

In addition to the standard set of options (see "COMMON OPTIONS")

BBeerrkkeelleeyyDDBB::::BBttrreeee supports these options:

-Property

Used to specify extra flags when opening a database. The following flags may be specified by bitwise OR'ing together one or more of the following values: DDBBDDUUPP When creating a new database, this flag enables the storing of duplicate keys in the database. If DDBBDDUUPPSSOORRTT is not specified as well, the duplicates are stored in the order they are created in the database. DDBBDDUUPPSSOORRTT Enables the sorting of duplicate keys in the database. Ignored if DDBBDDUUPP isn't also specified. Minkey TODO Compare Allow you to override the default sort order used in the database. See "Changing the sort order" for an example. sub compare {

my ($key, $key2) = @ ;

...

# return 0 if $key1 eq $key2

# -1 if $key1 lt $key2

# 1 if $key1 gt $key2

return (-1 , 0 or 1) ;

}

tie %h, "BerkeleyDB::Hash",

-Filename => $filename,

-Compare => \&compare,

... Prefix sub prefix {

my ($key, $key2) = @ ;

...

# return number of bytes of $key2 which are

# necessary to determine that it is greater than $key1

return $bytes ;

}

tie %h, "BerkeleyDB::Hash",

-Filename => $filename,

-Prefix => \&prefix,

... =item DupCompare sub compare {

my ($key, $key2) = @ ;

...

# return 0 if $key1 eq $key2

# -1 if $key1 lt $key2

# 1 if $key1 gt $key2

return (-1 , 0 or 1) ;

}

tie %h, "BerkeleyDB::Hash",

-Filename => $filename,

-DupCompare => \&compare,

... Methods BBeerrkkeelleeyyDDBB::::BBttrreeee supports the following database methods. See also "COMMON DATABASE METHODS". All the methods below return 0 to indicate success.

$status = $db->dbkeyrange($key, $less, $equal, $greater [, $flags])

Given a key, $key, this method returns the proportion of keys less

than $key in $less, the proportion equal to $key in $equal and the

proportion greater than $key in $greater.

The proportion is returned as a double in the range 0.0 to 1.0. AA SSiimmppllee BBttrreeee EExxaammppllee The code below is a simple example of using a btree database. use strict ;

use BerkeleyDB ;

my $filename = "tree" ;

unlink $filename ;

my %h ;

tie %h, 'BerkeleyDB::Btree',

-Filename => $filename,

-Flags => DBCREATE

or die "Cannot open $filename: $! $BerkeleyDB::Error\n" ;

# Add a key/value pair to the file

$h{'Wall'} = 'Larry' ;

$h{'Smith'} = 'John' ;

$h{'mouse'} = 'mickey' ;

$h{'duck'} = 'donald' ;

# Delete

delete $h{"duck"} ;

# Cycle through the keys printing them in order.

# Note it is not necessary to sort the keys as

# the btree will have kept them in order automatically.

foreach (keys %h)

{ print "$\n" }

untie %h ;

Here is the output from the code above. The keys have been sorted using Berkeley DB's default sorting algorithm. Smith Wall mouse CChhaannggiinngg tthhee ssoorrtt oorrddeerr It is possible to supply your own sorting algorithm if the one that Berkeley DB used isn't suitable. The code below is identical to the previous example except for the case insensitive compare function. use strict ;

use BerkeleyDB ;

my $filename = "tree" ;

unlink $filename ;

my %h ;

tie %h, 'BerkeleyDB::Btree',

-Filename => $filename,

-Flags => DBCREATE,

-Compare => sub { lc $[0] cmp lc $[1] }

or die "Cannot open $filename: $!\n" ;

# Add a key/value pair to the file

$h{'Wall'} = 'Larry' ;

$h{'Smith'} = 'John' ;

$h{'mouse'} = 'mickey' ;

$h{'duck'} = 'donald' ;

# Delete

delete $h{"duck"} ;

# Cycle through the keys printing them in order.

# Note it is not necessary to sort the keys as

# the btree will have kept them in order automatically.

foreach (keys %h)

{ print "$\n" }

untie %h ;

Here is the output from the code above. mouse Smith Wall There are a few point to bear in mind if you want to change the ordering in a BTREE database: 1. The new compare function must be specified when you create the database. 2. You cannot change the ordering once the database has been created. Thus you must use the same compare function every time you access the database. UUssiinngg ddbbssttaatt TODO BBeerrkkeelleeyyDDBB::::RReeccnnoo qiaet o aln dbopen wt tp DBRECNO i Bree D 2x n

aln dbcreate floe b DB->open ih ye DBRECNO n ekly

DB 3.x or greater. Two forms of constructor are supported:

$db = new BerkeleyDB::Recno

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Recno specific

[ -Delim => byte,]

[ -Len => number,]

[ -Pad => byte,]

[ -Source => filename,]

and this

[$db =] tie @arry, 'BerkeleyDB::Recno',

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Recno specific

[ -Delim => byte,]

[ -Len => number,]

[ -Pad => byte,]

[ -Source => filename,]

AA RReeccnnoo EExxaammppllee Here is a simple example that uses RECNO (if you are using a version of

Perl earlier than 5.00457 this example won't work - see "Extra RECNO

Methods" for a workaround). use strict ;

use BerkeleyDB ;

my $filename = "text" ;

unlink $filename ;

my @h ;

tie @h, 'BerkeleyDB::Recno',

-Filename => $filename,

-Flags => DBCREATE,

-Property => DBRENUMBER

or die "Cannot open $filename: $!\n" ;

# Add a few key/value pairs to the file

$h[0] = "orange" ;

$h[1] = "blue" ;

$h[2] = "yellow" ;

push @h, "green", "black" ;

my $elements = scalar @h ;

print "The array contains $elements entries\n" ;

my $last = pop @h ;

print "popped $last\n" ;

unshift @h, "white" ;

my $first = shift @h ;

print "shifted $first\n" ;

# Check for existence of a key

print "Element 1 Exists with value $h[1]\n" if $h[1] ;

untie @h ; Here is the output from the script: The array contains 5 entries popped black shifted white Element 1 Exists with value blue The last element is green The 2nd last element is yellow BBeerrkkeelleeyyDDBB::::QQuueeuuee

Equivalent to calling ddbbccrreeaattee followed by DDBB->>ooppeenn with type DDBBQQUUEEUUEE

in Berkeley DB 3.x or greater. This database format isn't available if you use Berkeley DB 2.x. Two forms of constructor are supported:

$db = new BerkeleyDB::Queue

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Queue specific

[ -Len => number,]

[ -Pad => byte,]

[ -ExtentSize => number, ]

and this

[$db =] tie @arry, 'BerkeleyDB::Queue',

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ],

# BerkeleyDB::Queue specific

[ -Len => number,]

[ -Pad => byte,]

BBeerrkkeelleeyyDDBB::::UUnnkknnoowwnn This class is used to open an existing database. Equivalent to calling ddbbooppeenn with type DDBBUUNNKKNNOOWWNN in Berkeley DB 2.x

and calling ddbbccrreeaattee followed by DDBB->>ooppeenn with type DDBBUUNNKKNNOOWWNN in

Berkeley DB 3.x or greater. The constructor looks like this:

$db = new BerkeleyDB::Unknown

[ -Filename => "filename", ]

[ -Subname => "sub-database name", ]

[ -Flags => flags,]

[ -Property => flags,]

[ -Mode => number,]

[ -Cachesize => number,]

[ -Lorder => number,]

[ -Pagesize => number,]

[ -Env => $env,]

[ -Txn => $txn,]

[ -Encrypt => { Password => "string",

Flags => number }, ], AAnn eexxaammppllee CCOOMMMMOONN OOPPTTIIOONNSS All database access class constructors support the common set of options defined below. All are optional.

-Filename

The database filename. If no filename is specified, a temporary file will be created and removed once the program terminates.

-Subname

Specifies the name of the sub-database to open. This option is

only valid if you are using Berkeley DB 3.x or greater.

-Flags

Specify how the database will be opened/created. The valid flags are: DDBBCCRREEAATTEE Create any underlying files, as necessary. If the files do not already exist and the DDBBCCRREEAATTEE flag is not specified, the call will fail. DDBBNNOOMMMMAAPP

Not supported by BerkeleyDB.

DDBBRRDDOONNLLYY

Opens the database in read-only mode.

DDBBTTHHRREEAADD

Not supported by BerkeleyDB.

DDBBTTRRUUNNCCAATTEE If the database file already exists, remove all the data before opening it.

-Mode

Determines the file protection when the database is created. Defaults to 0666.

-Cachesize

-Lorder

-Pagesize

-Env When working under a Berkeley DB environment, this parameter

Defaults to no environment.

-Encrypt

If present, this parameter will enable encryption of all data before it is written to the database. This parameters must be given a hash reference. The format is shown below.

-Encrypt => { -Password => "abc", Flags => DBENCRYPTAES }

Valid values for the Flags are 0 or "DBENCRYPTAES". This option requires Berkeley DB 4.1 or better.

-Txn TODO.

CCOOMMMMOONN DDAATTAABBAASSEE MMEETTHHOODDSS All the database interfaces support the common set of methods defined below. All the methods below return 0 to indicate success.

$$ssttaattuuss = $db->dbget($key, $value [, $flags])

Given a key ($key) this method reads the value associated with it from

the database. If it exists, the value read from the database is

returned in the $value parameter.

The $$ffllaaggss parameter is optional. If present, it must be set to oonnee of

the following values: DDBBGGEETTBBOOTTHH When the DDBBGGEETTBBOOTTHH flag is specified, ddbbggeett checks for the

existence of bbootthh the $key aanndd $value in the database.

DDBBSSEETTRREECCNNOO TODO. In addition, the following value may be set by bitwise OR'ing it into

the $$ffllaaggss parameter:

DDBBRRMMWW TODO

$$ssttaattuuss = $db->dbput($key, $value [, $flags])

Stores a key/value pair in the database.

The $$ffllaaggss parameter is optional. If present it must be set to oonnee of

the following values: DDBBAAPPPPEENNDD This flag is only applicable when accessing a BBeerrkkeelleeyyDDBB::::RReeccnnoo database. TODO. DDBBNNOOOOVVEERRWWRRIITTEE

If this flag is specified and $key already exists in the database,

the call to ddbbppuutt will return DDBBKKEEYYEEXXIISSTT.

$$ssttaattuuss = $db->dbdel($key [, $flags])

Deletes a key/value pair in the database associated with $key. If

duplicate keys are enabled in the database, ddbbddeell will delete aallll

key/value pairs with key $key.

The $$ffllaaggss parameter is optional and is currently unused.

$$ssttaattuuss = $db->dbsync()

If any parts of the database are in memory, write them to the database.

$$ccuurrssoorr = $db->dbcursor([$flags])

Creates a cursor object. This is used to access the contents of the database sequentially. See CURSORS for details of the methods available when working with cursors.

The $$ffllaaggss parameter is optional. If present it must be set to oonnee of

the following values: DDBBRRMMWW TODO.

(($$ffllaagg,, $$oollddooffffsseett, $oldlength) = $db->partialset($offset, $length)

; TODO

(($$ffllaagg,, $$oollddooffffsseett, $oldlength) = $db->partialclear() ;

TODO

$$ddbb->byteswapped()

TODO

$$ddbb->type()

Returns the type of the database. The possible return code are DDBBHHAASSHH for a BBeerrkkeelleeyyDDBB::::HHaasshh database, DDBBBBTTRREEEE for a BBeerrkkeelleeyyDDBB::::BBttrreeee

aaae n DBRECNO fr BerkeleyDB::Recno dtbs. hs ehd s

typically used when a database has been opened with BBeerrkkeelleeyyDDBB::::UUnnkknnoowwnn.

$$bbooooll = $env->cdsenabled();

Returns true if the Berkeley DB environment $env has been opened on CDS

mode.

$$bbooooll = $db->cdsenabled();

Returns true if the database $db has been opened on CDS mode.

$$lloocckk = $db->cdslock();

Creates a CDS write lock object $lock.

It is a fatal error to attempt to create a cdslock if the Berkeley DB environment has not been opened in CDS mode.

$$lloocckk->cdsunlock();

Removes a CDS lock. The destruction of the CDS lock object automatically calls this method. Note that if multiple CDS lock objects are created, the underlying write lock will not be released until all CDS lock objects are either explictly unlocked with this method, or the CDS lock objects have been destroyed.

$$rreeff = $db->dbstat()

Returns a reference to an associative array containing information about the database. The keys of the associative array correspond directly to the names of the fields defined in the Berkeley DB documentation. For example, in the DB documentation, the field bbttvveerrssiioonn stores the version of the Btree database. Assuming you called ddbbssttaatt on a Btree database the equivalent field would be accessed as follows:

$version = $ref->{'btversion'} ;

If you are using Berkeley DB 3.x or better, this method will work will all database formats. When DB 2.x is used, it only works with BBeerrkkeelleeyyDDBB::::BBttrreeee.

$$ssttaattuuss = $db->status()

Returns the status of the last $db method called.

$$ssttaattuuss = $db->truncate($count)

Truncates the datatabase and returns the number or records deleted in

$count.

$$ssttaattuuss = $db->compact($start, $stop, $cdata, $flags, $end);

Compacts the database $db.

All the parameters are optional - if only want to make use of some of

them, use "undef" for those you don't want. Trailing unusused parameters can be omitted. For example, if you only want to use the

$cdata parameter to set the "compactfillpercent", write you code like

this

my %hash;

$hash{compactfillpercent} = 50;

$db->commit(undef, undef, \%hash);

The parameters operate identically to the C equivalent of this method.

The $cdata needs a bit of explanation - it must be a hash reference.

The values of the following keys can be set before calling "compact" and will affect the operation of the compaction. The following keys, along with associated values, will be created in the hash reference if the "compact" operation was successful. +o compactdeadlock =item * compactlevels =item * compactpagesfree =item * compactpagesexamine =item * compactpagestruncated You need to be running Berkeley DB 4.4 or better if you wan to make use of "compact". CCUURRSSOORRSS A cursor is used whenever you want to access the contents of a database in sequential order. A cursor object is created with the "dbcursor" A cursor object has the following methods available:

$$nneewwccuurrssoorr = $cursor->cdup($flags)

Creates a duplicate of $cursor. This method needs Berkeley DB 3.0.x or

better.

The $flags parameter is optional and can take the following value:

DBPOSITION When present this flag will position the new cursor at the same place as the existing cursor.

$$ssttaattuuss = $cursor->cget($key, $value, $flags)

Reads a key/value pair from the database, returning the data in $key

and $value. The key/value pair actually read is controlled by the

$flags parameter, which can take oonnee of the following values:

DDBBFFIIRRSSTT Set the cursor to point to the first key/value pair in the

database. Return the key/value pair in $key and $value.

DDBBLLAASSTT Set the cursor to point to the last key/value pair in the

database. Return the key/value pair in $key and $value.

DDBBNNEEXXTT If the cursor is already pointing to a key/value pair, it will be incremented to point to the next key/value pair and return its contents. If the cursor isn't initialised, DDBBNNEEXXTT works just like DDBBFFIIRRSSTT. If the cursor is already positioned at the last key/value pair, ccggeett will return DDBBNNOOTTFFOOUUNNDD. DDBBNNEEXXTTDDUUPP This flag is only valid when duplicate keys have been enabled in a database. If the cursor is already pointing to a key/value pair and the key of the next key/value pair is identical, the cursor will be incremented to point to it and their contents returned. DDBBPPRREEVV If the cursor is already pointing to a key/value pair, it will be decremented to point to the previous key/value pair and return its contents. If the cursor isn't initialised, DDBBPPRREEVV works just like DDBBLLAASSTT. If the cursor is already positioned at the first key/value pair, ccggeett will return DDBBNNOOTTFFOOUUNNDD. DDBBCCUURRRREENNTT If the cursor has been set to point to a key/value pair, return their contents. If the key/value pair referenced by the cursor has been deleted, ccggeett will return DDBBKKEEYYEEMMPPTTYY. DDBBSSEETT

Set the cursor to point to the key/value pair referenced by $$kkeeyy

and return the value in $$vvaalluuee.

DDBBSSEETTRRAANNGGEE This flag is a variation on the DDBBSSEETT flag. As well as returning

the value, it also returns the key, via $$kkeeyy. When used with a

BBeerrkkeelleeyyDDBB::::BBttrreeee database the key matched by ccggeett will be the shortest key (in length) which is greater than or equal to the key

supplied, via $$kkeeyy. This allows partial key searches. See ??? for

an example of how to use this flag. DDBBGGEETTBBOOTTHH Another variation on DDBBSSEETT. This one returns both the key and the value. DDBBSSEETTRREECCNNOO TODO. DDBBGGEETTRREECCNNOO TODO. In addition, the following value may be set by bitwise OR'ing it into

the $$ffllaaggss parameter:

DDBBRRMMWW TODO.

$$ssttaattuuss = $cursor->cput($key, $value, $flags)

Stores the key/value pair in the database. The position that the data

is stored in the database is controlled by the $flags parameter, which

must take oonnee of the following values: DDBBAAFFTTEERR When used with a Btree or Hash database, a duplicate of the key referenced by the current cursor position will be created and the

contents of $$vvaalluuee will be associated with it - $$kkeeyy is ignored.

The new key/value pair will be stored immediately after the current cursor position. Obviously the database has to have been opened with DDBBDDUUPP. When used with a Recno ... TODO DDBBBBEEFFOORREE When used with a Btree or Hash database, a duplicate of the key referenced by the current cursor position will be created and the

contents of $$vvaalluuee will be associated with it - $$kkeeyy is ignored.

The new key/value pair will be stored immediately before the current cursor position. Obviously the database has to have been opened with DDBBDDUUPP. When used with a Recno ... TODO DDBBCCUURRRREENNTT If the cursor has been initialised, replace the value of the

key/value pair stored in the database with the contents of $$vvaalluuee.

DDBBKKEEYYFFIIRRSSTT Only valid with a Btree or Hash database. This flag is only really used when duplicates are enabled in the database and sorted duplicates haven't been specified. In this case the key/value pair will be inserted as the first entry in the duplicates for the particular key. DDBBKKEEYYLLAASSTT Only valid with a Btree or Hash database. This flag is only really used when duplicates are enabled in the database and sorted duplicates haven't been specified. In this case the key/value pair will be inserted as the last entry in the duplicates for the particular key.

$$ssttaattuuss = $cursor->cdel([$flags])

This method deletes the key/value pair associated with the current cursor position. The cursor position will not be changed by this operation, so any subsequent cursor operation must first initialise the cursor to point to a valid key/value pair. If the key/value pair associated with the cursor have already been deleted, ccddeell will return DDBBKKEEYYEEMMPPTTYY.

The $$ffllaaggss parameter is not used at present.

$$ssttaattuuss = $cursor->ccount($cnt [, $flags])

Stores the number of duplicates at the current cursor position in $$ccnntt.

The $$ffllaaggss parameter is not used at present. This method needs Berkeley

DB 3.1 or better.

$$ssttaattuuss = $cursor->status()

Returns the status of the last cursor method as a dual type.

$$ssttaattuuss = $cursor->cpget() ;

TODO

$$ssttaattuuss = $cursor->cclose()

Closes the cursor $$ccuurrssoorr.

CCuurrssoorr EExxaammpplleess TODO Iterating from first to last, then in reverse. examples of each of the flags. JJOOIINN

Join support for BerkeleyDB is in progress. Watch this space.

TODO TTRRAANNSSAACCTTIIOONNSS TODO. CCDDSS MMooddee The Berkeley Db Concurrent Data Store is a lightweight locking mechanism that is useful in scenarios where transactions are overkill. See the accompanying document .. for details of using this module in CDS mode. DDBBMM FFiilltteerrss A DBM Filter is a piece of code that is be used when you always want to make the same transformation to all keys and/or values in a DBM

database. All of the database classes (BerkeleyDB::Hash,

BerkeleyDB::Btree and BerkeleyDB::Recno) support DBM Filters.

There are four methods associated with DBM Filters. All work identically, and each is used to install (or uninstall) a single DBM Filter. Each expects a single parameter, namely a reference to a sub. The only difference between them is the place that the filter is installed. To summarise: ffiilltteerrssttoorreekkeeyy If a filter has been installed with this method, it will be invoked every time you write a key to a DBM database. ffiilltteerrssttoorreevvaalluuee If a filter has been installed with this method, it will be invoked every time you write a value to a DBM database. ffiilltteerrffeettcchhkkeeyy If a filter has been installed with this method, it will be invoked every time you read a key from a DBM database. ffiilltteerrffeettcchhvvaalluuee If a filter has been installed with this method, it will be invoked every time you read a value from a DBM database. You can use any combination of the methods, from none, to all four. All filter methods return the existing filter, if present, or "undef" in not. To delete a filter pass "undef" to it. The Filter

When each filter is called by Perl, a local copy of $ will contain the

key or value to be filtered. Filtering is achieved by modifying the

contents of $. The return code from the filter is ignored.

AAnn EExxaammppllee -- tthhee NNUULLLL tteerrmmiinnaattiioonn pprroobblleemm..

Consider the following scenario. You have a DBM database that you need

to share with a third-party C application. The C application assumes

that all keys and values are NULL terminated. Unfortunately when Perl writes to DBM databases it doesn't use NULL termination, so your Perl application will have to manage NULL termination itself. When you write to the database you will have to use something like this:

$hash{"$key\0"} = "$value\0" ;

Similarly the NULL needs to be taken into account when you are considering the length of existing keys/values. It would be much better if you could ignore the NULL terminations issue in the main application code and have a mechanism that automatically added the terminating NULL to all keys and values whenever you write to the database and have them removed when you read from the database. As I'm sure you have already guessed, this is a problem that DBM Filters can fix very easily. use strict ;

use BerkeleyDB ;

my %hash ;

my $filename = "filt.db" ;

unlink $filename ;

my $db = tie %hash, 'BerkeleyDB::Hash',

-Filename => $filename,

-Flags => DBCREATE

or die "Cannot open $filename: $!\n" ;

# Install DBM Filters

$db->filterfetchkey ( sub { s/\0$// } ) ;

$db->filterstorekey ( sub { $ .= "\0" } ) ;

$db->filterfetchvalue( sub { s/\0$// } ) ;

$db->filterstorevalue( sub { $ .= "\0" } ) ;

$hash{"abc"} = "def" ;

my $a = $hash{"ABC"} ;

# ...

undef $db ;

untie %hash ;

Hopefully the contents of each of the filters should be self-

explanatory. Both "fetch" filters remove the terminating NULL, and both "store" filters add a terminating NULL.

Another Example - Key is a C int.

Here is another real-life example. By default, whenever Perl writes to

a DBM database it always writes the key and value as strings. So when you use this:

$hash{12345} = "something" ;

the key 12345 will get stored in the DBM database as the 5 byte string "12345". If you actually want the key to be stored in the DBM database as a C int, you will have to use "pack" when writing, and "unpack" when reading. Here is a DBM Filter that does it: use strict ;

use BerkeleyDB ;

my %hash ;

my $filename = "filt.db" ;

unlink $filename ;

my $db = tie %hash, 'BerkeleyDB::Btree',

-Filename => $filename,

-Flags => DBCREATE

or die "Cannot open $filename: $!\n" ;

$db->filterfetchkey ( sub { $ = unpack("i", $) } ) ;

$db->filterstorekey ( sub { $ = pack ("i", $) } ) ;

$hash{123} = "def" ;

# ...

undef $db ;

untie %hash ;

This time only two filters have been used - we only need to manipulate

the contents of the key, so it wasn't necessary to install any value filters. UUssiinngg BBeerrkkeelleeyyDDBB wwiitthh MMLLDDBBMM

Both BerkeleyDB::Hash and BerkeleyDB::Btree can be used with the MLDBM

module. The code fragment below shows how to open associate MLDBM with

BerkeleyDB::Btree. To use BerkeleyDB::Hash just replace

BerkeleyDB::Btree with BerkeleyDB::Hash.

use strict ;

use BerkeleyDB ;

use MLDBM qw(BerkeleyDB::Btree) ;

use Data::Dumper;

my $filename = 'testmldbm' ;

my %o ;

unlink $filename ;

tie %o, 'MLDBM', -Filename => $filename,

-Flags => DBCREATE

or die "Cannot open database '$filename: $!\n";

See the MLDBM documentation for information on how to use the module and for details of its limitations. EEXXAAMMPPLLEESS TODO. HHIINNTTSS && TTIIPPSS SShhaarriinngg DDaattaabbaasseess WWiitthh CC AApppplliiccaattiioonnss There is no technical reason why a Berkeley DB database cannot be shared by both a Perl and a C application. The vast majority of problems that are reported in this area boil down to the fact that C strings are NULL terminated, whilst Perl strings are

not. See "An Example - the NULL termination problem." in the DBM

FILTERS section for a generic way to work around this problem. The untie Gotcha TODO COMMON QUESTIONS This section attempts to answer some of the more common questions that I get asked. RReellaattiioonnsshhiipp wwiitthh DDBBFFiillee Before Berkeley DB 2.x was written there was only one Perl module that interfaced to Berkeley DB. That module is called DDBBFFiillee. Although DDBBFFiillee can be build with Berkeley DB 1.x, 2.x, 3.x or 4.x, it only provides an interface to the functionality available in Berkeley DB 1.x. That means that it doesn't support transactions, locking or any of the other new features available in DB 2.x or better. HHooww ddoo II ssttoorree PPeerrll ddaattaa ssttrruuccttuurreess wwiitthh BBeerrkkeelleeyyDDBB??

See "Using BerkeleyDB with MLDBM".

HISTORY See the Changes file. AVAILABILITY The most recent version of BBeerrkkeelleeyyDDBB can always be found on CPAN (see "CPAN" in perlmod for details), in the directory

modules/by-module/BerkeleyDB.

The official web site for Berkeley DB is http://www.sleepycat.com. COPYRIGHT

Copyright (c) 1997-2004 Paul Marquess. All rights reserved. This

program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Although BBeerrkkeelleeyyDDBB is covered by the Perl license, the library it makes use of, namely Berkeley DB, is not. Berkeley DB has its own copyright and its own license. Please take the time to read it. Here are few words taken from the Berkeley DB FAQ (at http://www.sleepycat.com) regarding the license: Do I have to license DB to use it in Perl scripts? No. The Berkeley DB license requires that software that uses Berkeley DB be freely redistributable. In the case of Perl, that software is Perl, and not your scripts. Any Perl scripts that you write are your property, including scripts that make use of Berkeley DB. Neither the Perl license nor the Berkeley DB license place any restriction on what you may do with them. If you are in any doubt about the license situation, contact either the

Berkeley DB authors or the author of BerkeleyDB. See "AUTHOR" for

details. AUTHOR Paul Marquess . Questions about Berkeley DB may be addressed to .

SEE ALSO

perl(1), DBFile, Berkeley DB.

perl v5.8.8 2006-07-02 BerkeleyDB(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™