line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
923
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Config::INI::Reader::Ordered 0.021; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: .ini-file parser that returns sections in order |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
563
|
use Config::INI::Reader; |
|
1
|
|
|
|
|
54171
|
|
|
1
|
|
|
|
|
55
|
|
8
|
1
|
|
|
1
|
|
11
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
9
|
1
|
|
|
1
|
|
249
|
BEGIN { @ISA = qw(Config::INI::Reader) } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod If F contains: |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod admin = rjbs |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod [rjbs] |
18
|
|
|
|
|
|
|
#pod awesome = yes |
19
|
|
|
|
|
|
|
#pod height = 5' 10" |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod [mj] |
22
|
|
|
|
|
|
|
#pod awesome = totally |
23
|
|
|
|
|
|
|
#pod height = 23" |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod Then when your program contains: |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod my $array = Config::INI::Reader->read_file('family.ini'); |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod C<$array> will contain: |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod [ |
32
|
|
|
|
|
|
|
#pod [ '_' => { admin => 'rjbs' } ], |
33
|
|
|
|
|
|
|
#pod [ |
34
|
|
|
|
|
|
|
#pod rjbs => { |
35
|
|
|
|
|
|
|
#pod awesome => 'yes', |
36
|
|
|
|
|
|
|
#pod height => q{5' 10"}, |
37
|
|
|
|
|
|
|
#pod } |
38
|
|
|
|
|
|
|
#pod ], |
39
|
|
|
|
|
|
|
#pod [ |
40
|
|
|
|
|
|
|
#pod mj => { |
41
|
|
|
|
|
|
|
#pod awesome => 'totally', |
42
|
|
|
|
|
|
|
#pod height => '23"', |
43
|
|
|
|
|
|
|
#pod } |
44
|
|
|
|
|
|
|
#pod ], |
45
|
|
|
|
|
|
|
#pod ] |
46
|
|
|
|
|
|
|
#pod |
47
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
48
|
|
|
|
|
|
|
#pod |
49
|
|
|
|
|
|
|
#pod Config::INI::Reader::Ordered is a subclass of L which |
50
|
|
|
|
|
|
|
#pod preserves section order. See L for all documentation; the |
51
|
|
|
|
|
|
|
#pod only difference is as presented in the L. |
52
|
|
|
|
|
|
|
#pod |
53
|
|
|
|
|
|
|
#pod =cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub change_section { |
56
|
6
|
|
|
6
|
1
|
2868
|
my ($self, $section) = @_; |
57
|
6
|
|
|
|
|
29
|
$self->SUPER::change_section($section); |
58
|
6
|
|
100
|
|
|
81
|
$self->{order} ||= []; |
59
|
5
|
|
|
|
|
20
|
push @{ $self->{order} }, $section |
60
|
6
|
100
|
|
|
|
14
|
unless grep { $_ eq $section } @{ $self->{order} }; |
|
9
|
|
|
|
|
32
|
|
|
6
|
|
|
|
|
19
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub set_value { |
64
|
9
|
|
|
9
|
1
|
4857
|
my ($self, $name, $value) = @_; |
65
|
9
|
|
|
|
|
39
|
$self->SUPER::set_value($name, $value); |
66
|
9
|
100
|
|
|
|
132
|
unless ($self->{order}) { |
67
|
2
|
|
|
|
|
7
|
$self->{order} = [ $self->starting_section ]; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub finalize { |
72
|
3
|
|
|
3
|
1
|
151
|
my ($self) = @_; |
73
|
3
|
|
|
|
|
13
|
my $data = []; |
74
|
3
|
50
|
|
|
|
8
|
for my $section (@{ $self->{order} || [] }) { |
|
3
|
|
|
|
|
17
|
|
75
|
7
|
|
|
|
|
32
|
push @$data, [ $section, $self->{data}{$section} ]; |
76
|
|
|
|
|
|
|
} |
77
|
3
|
|
|
|
|
14
|
$self->{data} = $data; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |