NAME

Config::IniHashReadDeep - Loads INI config as deep hashes

SYNOPSIS

use Config::IniHashReadDeep 'get_ini_file'; 

my $inihash = get_ini_file( $file );

# or OO style:

use Config::IniHashReadDeep;
use Data::Dumper;

my $ini = Config::IniHashReadDeep->new( $file )->get_ini();

print Dumper($ini);

Example ini file:

[main]
test=5
foo.bar=123
foo.more=77

[digits]
with.counting.000=111
with.counting.001=112
with.counting.002=113


[digitsmore]
with.counting.001.foo=111f
with.counting.003.bar=111b

The example above will print that:

$VAR1 = {                                                                                          
          'digitsmore' => {                                                                        
                            'with' => {                                                            
                                        'counting' => [                                            
                                                        undef,                                     
                                                        {                                          
                                                          'foo' => '111f'
                                                        },
                                                        undef,
                                                        {
                                                          'bar' => '111b'
                                                        }
                                                      ]
                                      }
                          },
          'main' => {
                      'test' => '5',
                      'foo' => {
                                'bar' => '123',
                                'more' => '77'
                              }
                    },
          'digits' => {
                        'with' => {
                                    'counting' => [
                                                    '111',
                                                    '112',
                                                    '113'
                                                  ]
                                  }
                      }
        };

DESCRIPTION

It is a wrapper using Config::IniHash, but only for loading and it does something special; using the entries as paths, delimited by '.' and building a hash tree of it.

REQUIRES

Exporter

Config::IniHash

METHODS

new

my $inihash = $this->new(%options);

At least it takes a filename. For further values, please have a look into Config::IniHash

You may set a different 'delimiter'.

get_ini

my \%inihash = $this->get_ini();

Returns the deep ini

get_ini_file

my \%inihash = get_ini_file($filename);

this is not a method, but a static function, which you can also import like that:

use Config::IniHashReadDeep 'get_ini_file';
my $inihash = get_ini_file( $file );

Paths

The paths used in the ini must be delimited with dotts. But you can set an own delimiter via setting 'delimiter' in the constructor.

Numbers

If you use numbers in the path elements, it will use an ARRAY instead of an HASH to place the value. Please note, that starting with high numbers or leaving gaps in numbers, causes undef entries. It will be up to you later to check wether there is a value or not.

Using numbers gives you the possibility to order entries.

AUTHOR

Andreas Hernitscheck ahernit(AT)cpan.org

LICENSE

You can redistribute it and/or modify it under the conditions of LGPL.