/usr/share/perl5/Config/INI/Reader/Ordered.pm is in libconfig-ini-reader-ordered-perl 0.020-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | use strict;
package Config::INI::Reader::Ordered;
$Config::INI::Reader::Ordered::VERSION = '0.020';
# ABSTRACT: .ini-file parser that returns sections in order
use Config::INI::Reader;
use vars qw(@ISA $VERSION);
BEGIN { @ISA = qw(Config::INI::Reader) }
#pod =head1 SYNOPSIS
#pod
#pod If F<family.ini> contains:
#pod
#pod admin = rjbs
#pod
#pod [rjbs]
#pod awesome = yes
#pod height = 5' 10"
#pod
#pod [mj]
#pod awesome = totally
#pod height = 23"
#pod
#pod Then when your program contains:
#pod
#pod my $array = Config::INI::Reader->read_file('family.ini');
#pod
#pod C<$array> will contain:
#pod
#pod [
#pod [ '_' => { admin => 'rjbs' } ],
#pod [
#pod rjbs => {
#pod awesome => 'yes',
#pod height => q{5' 10"},
#pod }
#pod ],
#pod [
#pod mj => {
#pod awesome => 'totally',
#pod height => '23"',
#pod }
#pod ],
#pod ]
#pod
#pod =head1 DESCRIPTION
#pod
#pod Config::INI::Reader::Ordered is a subclass of L<Config::INI::Reader> which
#pod preserves section order. See L<Config::INI::Reader> for all documentation; the
#pod only difference is as presented in the L</SYNOPSIS>.
#pod
#pod =cut
sub change_section {
my ($self, $section) = @_;
$self->SUPER::change_section($section);
$self->{order} ||= [];
push @{ $self->{order} }, $section
unless grep { $_ eq $section } @{ $self->{order} };
}
sub set_value {
my ($self, $name, $value) = @_;
$self->SUPER::set_value($name, $value);
unless ($self->{order}) {
$self->{order} = [ $self->starting_section ];
}
}
sub finalize {
my ($self) = @_;
my $data = [];
for my $section (@{ $self->{order} || [] }) {
push @$data, [ $section, $self->{data}{$section} ];
}
$self->{data} = $data;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Config::INI::Reader::Ordered - .ini-file parser that returns sections in order
=head1 VERSION
version 0.020
=head1 SYNOPSIS
If F<family.ini> contains:
admin = rjbs
[rjbs]
awesome = yes
height = 5' 10"
[mj]
awesome = totally
height = 23"
Then when your program contains:
my $array = Config::INI::Reader->read_file('family.ini');
C<$array> will contain:
[
[ '_' => { admin => 'rjbs' } ],
[
rjbs => {
awesome => 'yes',
height => q{5' 10"},
}
],
[
mj => {
awesome => 'totally',
height => '23"',
}
],
]
=head1 DESCRIPTION
Config::INI::Reader::Ordered is a subclass of L<Config::INI::Reader> which
preserves section order. See L<Config::INI::Reader> for all documentation; the
only difference is as presented in the L</SYNOPSIS>.
=head1 AUTHOR
Hans Dieter Pearcey <hdp@cpan.org>
=head1 CONTRIBUTOR
=for stopwords Ricardo Signes
Ricardo Signes <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2008 by Hans Dieter Pearcey.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|