1 package Config::Any::INI;
6 our $MAP_SECTION_SPACE_TO_NESTED_KEY = 1;
10 Config::Any::INI - Load INI config files
14 Loads INI files. Example:
28 return an array of valid extensions (C<ini>).
38 Attempts to load C<$file> as an INI file.
47 my $config = Config::Tiny->read( $file );
48 my $out = delete $config->{ _ } || {};
50 for my $k ( keys %$config ) {
51 my @keys = split /\s+/, $k;
52 my $ref = $config->{ $k };
54 if ( $MAP_SECTION_SPACE_TO_NESTED_KEY && @keys > 1 ) {
55 my ( $a, $b ) = @keys[ 0, 1 ];
56 $out->{ $a }->{ $b } = $ref;
59 $out->{ $k } = { %{ $out->{ $k } || {} }, %$ref };
66 =head2 is_supported( )
68 Returns true if L<Config::Tiny> is available.
73 eval { require Config::Tiny; };
77 =head1 PACKAGE VARIABLES
81 =item $MAP_SECTION_SPACE_TO_NESTED_KEY (boolean)
83 This variable controls whether spaces in INI section headings will be expanded into nested hash keys.
84 e.g. it controls whether [Full Power] maps to $config->{'Full Power'} or $config->{'Full'}->{'Power'}
86 By default it is set to 1 (i.e. true).
88 Set it to 0 to preserve literal spaces in section headings:
92 $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0;
98 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
100 Joel Bernstein E<lt>rataxis@cpan.orgE<gt>
102 =head1 COPYRIGHT AND LICENSE
104 Copyright 2007 by Brian Cassidy, portions copyright 2006, 2007 by Joel Bernstein
106 This library is free software; you can redistribute it and/or modify
107 it under the same terms as Perl itself.
115 =item * L<Config::Any>
117 =item * L<Config::Tiny>