# DB_File.pm -- Perl 5 interface to Berkeley DB
#
# written by Paul Marquess (Paul.Marquess@btinternet.com)
-# last modified 26th April 2000
-# version 1.73
+# last modified 10th December 2000
+# version 1.74
#
# Copyright (c) 1995-2000 Paul Marquess. All rights reserved.
# This program is free software; you can redistribute it and/or
require 5.003 ;
+use warnings;
use strict;
use Carp;
require Tie::Hash;
package DB_File::RECNOINFO ;
+use warnings;
use strict ;
@DB_File::RECNOINFO::ISA = qw(DB_File::HASHINFO) ;
package DB_File::BTREEINFO ;
+use warnings;
use strict ;
@DB_File::BTREEINFO::ISA = qw(DB_File::HASHINFO) ;
package DB_File ;
+use warnings;
use strict;
use vars qw($VERSION @ISA @EXPORT $AUTOLOAD $DB_BTREE $DB_HASH $DB_RECNO
$db_version $use_XSLoader
use Carp;
-$VERSION = "1.73" ;
+$VERSION = "1.74" ;
#typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
$DB_BTREE = new DB_File::BTREEINFO ;
sub CLEAR
{
my $self = shift;
- my $key = "" ;
+ my $key = 0 ;
my $value = "" ;
my $status = $self->seq($key, $value, R_FIRST());
my @keys;
database, delete keys/value pairs and finally how to enumerate the
contents of the database.
+ use warnings ;
use strict ;
use DB_File ;
use vars qw( %h $k $v ) ;
BTREE uses. Instead of using the normal lexical ordering, a case
insensitive compare function will be used.
+ use warnings ;
use strict ;
use DB_File ;
want to manipulate a BTREE database with duplicate keys. Consider this
code:
+ use warnings ;
use strict ;
use DB_File ;
Here is the script above rewritten using the C<seq> API method.
+ use warnings ;
use strict ;
use DB_File ;
So assuming the database created above, we can use C<get_dup> like
this:
+ use warnings ;
use strict ;
use DB_File ;
Assuming the database from the previous example:
+ use warnings ;
use strict ;
use DB_File ;
Again assuming the existence of the C<tree> database
+ use warnings ;
use strict ;
use DB_File ;
In the example script below, the C<match> sub uses this feature to find
and print the first matching key/value pair given a partial key.
+ use warnings ;
use strict ;
use DB_File ;
use Fcntl ;
of Perl earlier than 5.004_57 this example won't work -- see
L<Extra RECNO Methods> for a workaround).
+ use warnings ;
use strict ;
use DB_File ;
described above. It also makes use of the API interface directly (see
L<THE API INTERFACE>).
+ use warnings ;
use strict ;
use vars qw(@h $H $file $i) ;
use DB_File ;
sure you have already guessed, this is a problem that DBM Filters can
fix very easily.
+ use warnings ;
use strict ;
use DB_File ;
Here is a DBM Filter that does it:
+ use warnings ;
use strict ;
use DB_File ;
my %hash ;
I<ggh> script (available from your nearest CPAN archive in
F<authors/id/TOMC/scripts/nshist.gz>).
+ use warnings ;
use strict ;
use DB_File ;
use Fcntl ;
C<strict 'subs'> pragma (or the full strict pragma) in your script.
Consider this script:
+ use warnings ;
use strict ;
use DB_File ;
use vars qw(%x) ;