| 1 | package Dist::Surveyor::DB_File; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 3 | ▶ | use Storable qw(freeze thaw); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 3 | our $VERSION = '0.023'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | 3 | our @ISA; | |||||||||||||
| 10 | 0 | ▶ | if (eval { require DB_File; 1; }) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 11 | 0 | @ISA = ('DB_File'); | |||||||||||||
| 12 | |||||||||||||||
| 13 | } | ||||||||||||||
| 14 | 3 | elsif (eval { require SDBM_File; 1; }) { | |||||||||||||
| 15 | 3 | @ISA = ('SDBM_File'); | |||||||||||||
| 16 | } | ||||||||||||||
| 17 | else { | ||||||||||||||
| 18 | 0 | 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 | 0 | ▶ | sub STORE { | ||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||
| 25 | 0 | my ($self, $key, $val) = @_; | |||||||||||||
| 26 | 0 | $self->SUPER::STORE($key, freeze($val)); | |||||||||||||
| 27 | } | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 0 | ▶ | sub FETCH { | ||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||
| 30 | 0 | my ($self, $key) = @_; | |||||||||||||
| 31 | 0 | my $val = $self->SUPER::FETCH($key); | |||||||||||||
| 32 | 0 | return thaw($val); | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | 3 | return 1; | |||||||||||||