Brian Koontz > Config-IniSearch > Config::IniSearch

Download:
Config-IniSearch-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Config::IniSearch - Wrapper class for Config::IniHash to search for INI files

SYNOPSIS ^

    use Config::IniSearch;
    $config = new Config::IniSearch( 'inisection' );
    $val = $config->{param_name};

    use Config::IniSearch;
    $config = new Config::IniSearch( 'inisection', ['/usr/local/share/myfile.ini'] );
    $val = $config->{param_name};

DESCRIPTION ^

This module is intended to relieve the developer from having to keep track of the location and name of individual INI files. An INI file will be recognized by one of two names:

inisection.ini
$GLOBAL_INI.ini

Either/both of these must contain the section [inisection].

The following methods are available:

$config = new Config::IniSearch( $INISectionName, [$INIFileName, %IniHashOpts] );

The constructor requires one argument, a section name, $INISectionName. Optional arguments include a fully-qualified INI filename ($INIFileName) and options for Config::IniHash (see perldoc Config::IniHash). NOTE: By default, case is preserved.

$INIFileName must be set if passing in options for Config::IniHash. The section name does not need to be specified when accessing elements in $INISectionName:

$val = $config->{param_name};

When the constructor is invoked, the following list of defaults is searched for the appropriate INI file:

$INIFileName.ini
$cwd/$INISectionName.ini
$cwd/$GLOBAL_INI
scriptdir/$INISectionName.ini
scriptdir/$GLOBAL_INI
/etc/$INISectionName.ini
/etc/$GLOBAL_INI

Notice that the first INI file found will be the one used for subsequent lookups.

$inifile = $config->getINIFilename;

Returns the name of the INI file currently accessed by the object.

$section_name = $config->getSectionName;

Returns the name of the INI section name currently accessed by $config.

EXPORT ^

None by default.

AUTHOR ^

Brian Koontz <brian@pongonova.net>

COPYRIGHT ^

Copyright (c) 2003 Brian Koontz <brian@pongonova.net>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: