line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
809
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Config::INI::Reader::Ordered; |
4
|
|
|
|
|
|
|
$Config::INI::Reader::Ordered::VERSION = '0.020'; |
5
|
|
|
|
|
|
|
# ABSTRACT: .ini-file parser that returns sections in order |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
597
|
use Config::INI::Reader; |
|
1
|
|
|
|
|
48252
|
|
|
1
|
|
|
|
|
66
|
|
8
|
1
|
|
|
1
|
|
13
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
91
|
|
9
|
1
|
|
|
1
|
|
417
|
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
|
2510
|
my ($self, $section) = @_; |
57
|
6
|
|
|
|
|
19
|
$self->SUPER::change_section($section); |
58
|
6
|
|
100
|
|
|
63
|
$self->{order} ||= []; |
59
|
5
|
|
|
|
|
16
|
push @{ $self->{order} }, $section |
|
9
|
|
|
|
|
26
|
|
60
|
6
|
100
|
|
|
|
8
|
unless grep { $_ eq $section } @{ $self->{order} }; |
|
6
|
|
|
|
|
14
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub set_value { |
64
|
9
|
|
|
9
|
1
|
4725
|
my ($self, $name, $value) = @_; |
65
|
9
|
|
|
|
|
27
|
$self->SUPER::set_value($name, $value); |
66
|
9
|
100
|
|
|
|
108
|
unless ($self->{order}) { |
67
|
2
|
|
|
|
|
6
|
$self->{order} = [ $self->starting_section ]; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub finalize { |
72
|
3
|
|
|
3
|
1
|
151
|
my ($self) = @_; |
73
|
3
|
|
|
|
|
5
|
my $data = []; |
74
|
3
|
50
|
|
|
|
4
|
for my $section (@{ $self->{order} || [] }) { |
|
3
|
|
|
|
|
12
|
|
75
|
7
|
|
|
|
|
19
|
push @$data, [ $section, $self->{data}{$section} ]; |
76
|
|
|
|
|
|
|
} |
77
|
3
|
|
|
|
|
10
|
$self->{data} = $data; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |