1 package Config::Any::INI;
6 use base 'Config::Any::Base';
8 our $MAP_SECTION_SPACE_TO_NESTED_KEY = 1;
12 Config::Any::INI - Load INI config files
16 Loads INI files. Example:
30 return an array of valid extensions (C<ini>).
40 Attempts to load C<$file> as an INI file.
49 my $config = Config::Tiny->read( $file );
51 die $Config::Tiny::errstr if not defined $config;
53 my $out = delete $config->{ _ } || {};
55 for my $k ( keys %$config ) {
56 my @keys = split /\s+/, $k;
57 my $ref = $config->{ $k };
59 if ( $MAP_SECTION_SPACE_TO_NESTED_KEY && @keys > 1 ) {
60 my ( $a, $b ) = @keys[ 0, 1 ];
61 $out->{ $a }->{ $b } = $ref;
64 $out->{ $k } = { %{ $out->{ $k } || {} }, %$ref };
71 =head2 requires_all_of( )
73 Specifies that this module requires L<Config::Tiny> in order to work.
77 sub requires_all_of { 'Config::Tiny' }
79 =head1 PACKAGE VARIABLES
83 =item $MAP_SECTION_SPACE_TO_NESTED_KEY (boolean)
85 This variable controls whether spaces in INI section headings will be expanded into nested hash keys.
86 e.g. it controls whether [Full Power] maps to $config->{'Full Power'} or $config->{'Full'}->{'Power'}
88 By default it is set to 1 (i.e. true).
90 Set it to 0 to preserve literal spaces in section headings:
94 $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0;
100 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
102 Joel Bernstein E<lt>rataxis@cpan.orgE<gt>
104 =head1 COPYRIGHT AND LICENSE
106 Copyright 2006-2009 by Brian Cassidy, portions copyright 2006, 2007 by Joel Bernstein
108 This library is free software; you can redistribute it and/or modify
109 it under the same terms as Perl itself.
117 =item * L<Config::Any>
119 =item * L<Config::Tiny>