line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::ScalarFile; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22093
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
105
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings::register; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
617
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "1.12"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $count = 0; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub TIESCALAR { |
13
|
0
|
|
|
0
|
|
|
my $class = shift; |
14
|
0
|
|
|
|
|
|
my $filename = shift; |
15
|
0
|
|
|
|
|
|
my $fh; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
0
|
|
|
|
if (open $fh, "<", $filename or |
18
|
|
|
|
|
|
|
open $fh, ">", $filename) |
19
|
|
|
|
|
|
|
{ |
20
|
0
|
|
|
|
|
|
close $fh; |
21
|
0
|
|
|
|
|
|
$count++; |
22
|
0
|
|
|
|
|
|
return bless \$filename, $class; |
23
|
|
|
|
|
|
|
} |
24
|
0
|
0
|
|
|
|
|
carp "Can't tie $filename: $!" if warnings::enabled(); |
25
|
0
|
|
|
|
|
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub FETCH { |
29
|
0
|
|
|
0
|
|
|
my $self = shift; |
30
|
0
|
0
|
|
|
|
|
confess "I am not a class method" unless ref $self; |
31
|
0
|
0
|
|
|
|
|
return unless open my $fh, $$self; |
32
|
0
|
|
|
|
|
|
read ($fh, my $value, -s $fh); |
33
|
0
|
|
|
|
|
|
return $value; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub STORE { |
37
|
0
|
|
|
0
|
|
|
my ($self, $value) = @_; |
38
|
0
|
0
|
|
|
|
|
ref $self or confess "not a class method"; |
39
|
0
|
0
|
|
|
|
|
open my $fh, ">", $self or croak "can't clobber $$self: $!"; |
40
|
0
|
0
|
|
|
|
|
syswrite ($fh, $value) == length $value |
41
|
|
|
|
|
|
|
or croak "can't write to $$self: $!"; |
42
|
0
|
0
|
|
|
|
|
close $fh or croak "can't close $$self: $!"; |
43
|
0
|
|
|
|
|
|
return $value; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub DESTROY { |
47
|
0
|
|
|
0
|
|
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
|
confess "wrong type" unless ref $self; |
49
|
0
|
|
|
|
|
|
$count--; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
sub count { $count } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
__END__ |