line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package My::ConfigPl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
372
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
23
|
use Data::Dumper (); |
|
1
|
|
|
|
|
7262
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
7
|
1
|
|
|
1
|
|
6
|
use File::Path qw( mkpath ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
391
|
|
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
|
19
|
my $class = shift; |
15
|
1
|
|
|
|
|
2
|
my $data; |
16
|
1
|
50
|
|
|
|
7
|
if(-e $class->file) |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
|
|
3
|
$data = do "./@{[ $class->file ]}"; |
|
1
|
|
|
|
|
3
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
|
|
0
|
$data = { 'test-key' => 'test-value' }; |
23
|
|
|
|
|
|
|
} |
24
|
1
|
|
|
|
|
9
|
bless { data => $data }, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get |
28
|
|
|
|
|
|
|
{ |
29
|
3
|
|
|
3
|
0
|
41
|
my($self, $name) = @_; |
30
|
3
|
|
|
|
|
23
|
$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; |