line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package My::ConfigPl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
390
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
22
|
use Data::Dumper (); |
|
1
|
|
|
|
|
7480
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
8
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
75
|
|
7
|
1
|
|
|
1
|
|
8
|
use File::Path qw( mkpath ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
433
|
|
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
|
15
|
my $class = shift; |
15
|
1
|
|
|
|
|
1
|
my $data; |
16
|
1
|
50
|
|
|
|
6
|
if(-e $class->file) |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
|
|
3
|
$data = do "./@{[ $class->file ]}"; |
|
1
|
|
|
|
|
5
|
|
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
|
50
|
my($self, $name) = @_; |
30
|
3
|
|
|
|
|
22
|
$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; |