-
Notifications
You must be signed in to change notification settings - Fork 0
/
HASHDB.pm
42 lines (32 loc) · 1.03 KB
/
HASHDB.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
################################################################################
## Purpose: This file contains subroutines to create and delete Berkeley DB file
## Berkeley DB is used to store the temporary data structures as key-value pairs
## This particular package is used in other files of the project
## Author: Vijay Shanker Karingula
## Language: Perl
##################################################################################
package HashDB;
use BerkeleyDB;
use Exporter;
our @ISA = 'Exporter';
our @EXPORT = qw($dbh);
our $dbh;
sub dbh_berkeleyDB {
my ($input_dir) = @_;
my $filename = <$input_dir/data.db>;
$dbh = new BerkeleyDB::Hash(
-Filename =>$filename,
-Flags =>DB_CREATE)
or die "Error opening $filename: $! $BerkeleyDB::Error\n";
return $dbh;
}
sub delete_berkeley{
my ($input_dir) = @_;
my $filename = <$input_dir/data.db>;
my $remove_status = BerkeleyDB::db_remove(
-Filename=>$filename);
#if($remove_status) {
#print "Old berkeleydb file is deleted\n";
#}
}
1;