BerkeleyDB/shared/scalar.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 67 CC 7 SCAR 20.8
CC
7
Cov
0%
STORE
20.0
new
6.0
FETCH
6.0
CRAP 8.0
1 package forks::BerkeleyDB::shared::scalar;
2  
3 $VERSION = 0.060;
4 use strict;
5 use warnings;
6 use BerkeleyDB 0.27;
7 use vars qw(@ISA);
8 @ISA = qw(BerkeleyDB::Recno);
9  
10 #---------------------------------------------------------------------------
11 sub new {
12 my $type = shift;
13 my $class = ref($type) || $type;
14 my $self = $class->SUPER::new(@_);
15 return undef unless defined $self;
16 return bless($self, $class);
17 }
18  
19 # standard Perl feature methods implemented:
20 # TIESCALAR
21 # FETCH, STORE
22 # UNTIE, DESTROY
23  
24 #---------------------------------------------------------------------------
25 *TIESCALAR = *TIESCALAR = \&new;
26  
27 #---------------------------------------------------------------------------
28 sub FETCH {
29 my ($key, $value) = (0, undef);
30 return undef unless $_[0]->db_get($key, $value) == 0;
31 return $value;
32 }
33  
34 sub STORE {
35 my $key = 0;
36 if (defined $_[1]) {
37 return undef unless $_[0]->db_put($key, $_[1]) == 0;
38 } else {
39 no warnings 'uninitialized';
40 return undef unless $_[0]->db_put($key, $_[1]) == 0;
41 }
42 return $_[1];
43 }
44  
45 #---------------------------------------------------------------------------
46 sub UNTIE {
47 eval { $_[0]->db_sync(); };
48 }
49  
50 sub DESTROY {
51 # eval { $_[0]->db_sync(); };
52 $_[0]->SUPER::DESTROY(@_) if $_[0];
53 }
54  
55 #---------------------------------------------------------------------------
56 1;
57  
58 __END__