line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##-*- Mode: CPerl -*- |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## File: Tie/File/Indexed/FreezeN.pm |
4
|
|
|
|
|
|
|
## Author: Bryan Jurish |
5
|
|
|
|
|
|
|
## Description: tied array access to indexed data files: Storable-frozen references (network byte-order) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Tie::File::Indexed::FreezeN; |
8
|
2
|
|
|
2
|
|
1052
|
use Tie::File::Indexed::Freeze; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
43
|
|
9
|
2
|
|
|
2
|
|
5
|
use Storable; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
90
|
|
10
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
191
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
##====================================================================== |
13
|
|
|
|
|
|
|
## Globals |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = qw(Tie::File::Indexed::Freeze); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
##====================================================================== |
18
|
|
|
|
|
|
|
## Subclass API: Data I/O: overrides |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## $bool = $tfi->writeData($data) |
21
|
|
|
|
|
|
|
## + override transparently encodes data using Storable::nfreeze() |
22
|
|
|
|
|
|
|
sub writeData { |
23
|
10
|
100
|
|
10
|
1
|
16
|
return 1 if (!defined($_[1])); ##-- don't waste space on undef |
24
|
9
|
|
|
|
|
14
|
return $_[0]{datfh}->print( Storable::nfreeze($_[1]) ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
## $data_or_undef = $tfi->readData($length) |
28
|
|
|
|
|
|
|
## + inherited method from Tie::File::Indexed::Freeze transparently decodes data using Storable::thaw() |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; ##-- be happpy |