line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Backend::INI; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26557
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
109
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
1120
|
use Config::IniFiles; |
|
1
|
|
|
|
|
36942
|
|
|
1
|
|
|
|
|
559
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION='0.12'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $DEFSECT="!!Conf::INI!!default!!"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
1
|
13
|
my $class=shift; |
13
|
1
|
|
|
|
|
3
|
my $file=shift; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
2
|
my $self; |
16
|
|
|
|
|
|
|
my $ini; |
17
|
|
|
|
|
|
|
|
18
|
1
|
50
|
33
|
|
|
33
|
if ((-z $file) or (not -e $file)) { |
19
|
0
|
|
|
|
|
0
|
$ini=new Config::IniFiles(); |
20
|
0
|
|
|
|
|
0
|
$ini->newval($DEFSECT,$DEFSECT,1); |
21
|
0
|
|
|
|
|
0
|
$ini->WriteConfig($file); |
22
|
|
|
|
|
|
|
} |
23
|
1
|
|
|
|
|
11
|
$ini=new Config::IniFiles(-file => $file); |
24
|
1
|
50
|
|
|
|
1648
|
if (not defined $ini) { |
25
|
0
|
|
|
|
|
0
|
die "Cannot open ini file $file\n"; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3
|
$self->{"ini"}=$ini; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
4
|
bless $self,$class; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
9
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub DESTROY { |
36
|
1
|
|
|
1
|
|
406
|
my $self=shift; |
37
|
1
|
|
|
|
|
4
|
$self->{"ini"}->RewriteConfig(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub set { |
41
|
5
|
|
|
5
|
1
|
4748
|
my $self=shift; |
42
|
5
|
|
|
|
|
11
|
my $_var=shift; |
43
|
5
|
|
|
|
|
7
|
my $val=shift; |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
20
|
my ($section,$var)=split /[.]/,$_var,2; |
46
|
5
|
100
|
|
|
|
19
|
if (not defined $var) { |
47
|
3
|
|
|
|
|
4
|
$var=$section; |
48
|
3
|
|
|
|
|
6
|
$section=$DEFSECT; |
49
|
|
|
|
|
|
|
} |
50
|
5
|
100
|
|
|
|
29
|
if (not defined $self->{"ini"}->setval($section,$var,$val)) { |
51
|
2
|
|
|
|
|
149
|
$self->{"ini"}->newval($section,$var,$val); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
499
|
$self->{"ini"}->RewriteConfig(); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub get { |
59
|
9
|
|
|
9
|
1
|
13455
|
my $self=shift; |
60
|
9
|
|
|
|
|
19
|
my $_var=shift; |
61
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
35
|
my ($section,$var)=split /[.]/,$_var,2; |
63
|
9
|
100
|
|
|
|
38
|
if (not defined $var) { |
64
|
4
|
|
|
|
|
9
|
$var=$section; |
65
|
4
|
|
|
|
|
10
|
$section=$DEFSECT; |
66
|
|
|
|
|
|
|
} |
67
|
9
|
|
|
|
|
48
|
return $self->{"ini"}->val($section,$var); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub del { |
71
|
2
|
|
|
2
|
1
|
337
|
my $self=shift; |
72
|
2
|
|
|
|
|
3
|
my $_var=shift; |
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
5
|
my ($section,$var)=split /[.]/,$_var,2; |
75
|
2
|
100
|
|
|
|
11
|
if (not defined $var) { |
76
|
1
|
|
|
|
|
2
|
$var=$section; |
77
|
1
|
|
|
|
|
3
|
$section=$DEFSECT; |
78
|
|
|
|
|
|
|
} |
79
|
2
|
|
|
|
|
9
|
$self->{"ini"}->delval($section,$var); |
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
119
|
$self->{"ini"}->RewriteConfig(); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub variables { |
86
|
2
|
|
|
2
|
1
|
1309
|
my $self=shift; |
87
|
2
|
|
|
|
|
6
|
my @vars; |
88
|
|
|
|
|
|
|
|
89
|
2
|
|
|
|
|
10
|
for my $s ($self->{"ini"}->Sections()) { |
90
|
4
|
|
|
|
|
46
|
for my $v ($self->{"ini"}->Parameters($s)) { |
91
|
8
|
100
|
|
|
|
186
|
if ($s eq $DEFSECT) { |
92
|
7
|
100
|
|
|
|
25
|
if ($v ne $DEFSECT) { |
93
|
5
|
|
|
|
|
18
|
push @vars,$v; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
else { |
97
|
1
|
|
|
|
|
17
|
push @vars,"$s.$v"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
2
|
|
|
|
|
24
|
return @vars; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |