File Coverage

blib/lib/Dist/Surveyor/DB_File.pm
Criterion Covered Total %
statement 9 14 64.2
branch n/a
condition n/a
subroutine 3 5 60.0
pod n/a
total 12 19 63.1


line stmt bran cond sub pod time code
1             package Dist::Surveyor::DB_File;
2              
3 3     3   20 use strict;
  3         6  
  3         76  
4 3     3   15 use warnings;
  3         6  
  3         89  
5 3     3   1535 use Storable qw(freeze thaw);
  3         6852  
  3         571  
6              
7             our $VERSION = '0.019';
8              
9             our @ISA;
10             if (eval { require DB_File; 1; }) {
11             @ISA = ('DB_File');
12              
13             }
14             elsif (eval { require SDBM_File; 1; }) {
15             @ISA = ('SDBM_File');
16             }
17             else {
18             die "Need either DB_file or SDBM_File installed to run";
19             }
20              
21             # DB_File can store only strings as values, and not Perl structures
22             # this small wrapper fixes the problem
23              
24             sub STORE {
25 0     0     my ($self, $key, $val) = @_;
26 0           $self->SUPER::STORE($key, freeze($val));
27             }
28              
29             sub FETCH {
30 0     0     my ($self, $key) = @_;
31 0           my $val = $self->SUPER::FETCH($key);
32 0           return thaw($val);
33             }
34              
35             return 1;