line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
641
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Config::INI::Reader::Ordered 0.022; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: .ini-file parser that returns sections in order |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
390
|
use Config::INI::Reader; |
|
1
|
|
|
|
|
44511
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
7
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
9
|
1
|
|
|
1
|
|
192
|
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
|
2112
|
my ($self, $section) = @_; |
57
|
6
|
|
|
|
|
20
|
$self->SUPER::change_section($section); |
58
|
6
|
|
100
|
|
|
56
|
$self->{order} ||= []; |
59
|
5
|
|
|
|
|
13
|
push @{ $self->{order} }, $section |
60
|
6
|
100
|
|
|
|
7
|
unless grep { $_ eq $section } @{ $self->{order} }; |
|
9
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
14
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub set_value { |
64
|
9
|
|
|
9
|
1
|
3418
|
my ($self, $name, $value) = @_; |
65
|
9
|
|
|
|
|
25
|
$self->SUPER::set_value($name, $value); |
66
|
9
|
100
|
|
|
|
91
|
unless ($self->{order}) { |
67
|
2
|
|
|
|
|
5
|
$self->{order} = [ $self->starting_section ]; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub finalize { |
72
|
3
|
|
|
3
|
1
|
117
|
my ($self) = @_; |
73
|
3
|
|
|
|
|
5
|
my $data = []; |
74
|
3
|
50
|
|
|
|
5
|
for my $section (@{ $self->{order} || [] }) { |
|
3
|
|
|
|
|
10
|
|
75
|
7
|
|
|
|
|
18
|
push @$data, [ $section, $self->{data}{$section} ]; |
76
|
|
|
|
|
|
|
} |
77
|
3
|
|
|
|
|
10
|
$self->{data} = $data; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |