line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package My::ConfigPl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
302
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
18
|
use Data::Dumper (); |
|
1
|
|
|
|
|
6291
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
5
|
use File::Path qw( mkpath ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
309
|
|
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
0
|
0
|
sub dir { croak "subclasss requires dir method" } |
10
|
0
|
|
|
0
|
0
|
0
|
sub file { croak "subclasss requires file method" } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
1
|
|
|
1
|
0
|
10
|
my $class = shift; |
15
|
1
|
|
|
|
|
1
|
my $data; |
16
|
1
|
50
|
|
|
|
5
|
if(-e $class->file) |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
|
|
2
|
$data = do "./@{[ $class->file ]}"; |
|
1
|
|
|
|
|
3
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
|
|
0
|
$data = { 'test-key' => 'test-value' }; |
23
|
|
|
|
|
|
|
} |
24
|
1
|
|
|
|
|
11
|
bless { data => $data }, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get |
28
|
|
|
|
|
|
|
{ |
29
|
3
|
|
|
3
|
0
|
31
|
my($self, $name) = @_; |
30
|
3
|
|
|
|
|
16
|
$self->{data}->{$name}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub set |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
0
|
0
|
|
my($self, $name, $value) = @_; |
36
|
0
|
|
|
|
|
|
$self->{data}->{$name} = $value; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $dd = Data::Dumper->new([$self->{data}],['x']) |
39
|
|
|
|
|
|
|
->Indent(1) |
40
|
|
|
|
|
|
|
->Terse(0) |
41
|
|
|
|
|
|
|
->Purity(1) |
42
|
|
|
|
|
|
|
->Sortkeys(1) |
43
|
|
|
|
|
|
|
->Dump; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
mkpath( $self->dir, 0, 0755 ) unless -d $self->dir; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $fh; |
48
|
0
|
0
|
|
|
|
|
open($fh, '>', $self->file) || die "error writing @{[ $self->file ]}"; |
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
print $fh 'do { my '; |
50
|
0
|
|
|
|
|
|
print $fh $dd; |
51
|
0
|
|
|
|
|
|
print $fh '$x;}'; |
52
|
0
|
|
|
|
|
|
close $fh; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |