Package DE_EPAGES::Core::API::IniConfig
Module for working with Windows-style .ini files.
Example |
my $IniConfig = DE_EPAGES::Core::API::IniConfig->new( FileName => 'c:/test/test.ini' ); my $Value = $IniConfig->get( 'Section 1', 'Key 1' ); $IniConfig->set( 'Section1', 'key2', 'value2' ); $IniConfig->rewrite(); An ini file has the following structure: [Section 1] Key 1=value1 key2=value2 private attributes ( for use inside this module only ): {FileName} - name of the config file {CaseSensitive} - flag set if keys and sections are case insensitive {Values} - hash of sections $self->{Values}->{$Section} is a hash of key-value pairs $self->{Values}->{$Section}->{$key} is a single value |
Package DE_EPAGES::Installer::API::CPANHelper::IniConfig
Functions
addSection
Adds a section to the ini file if the section not exists.
Syntax |
$IniConfig->addSection($Section); |
Return |
|
fileName
Sets or returns the config file name.
Syntax |
$IniConfig->fileName( $FileName ); $FileName = $IniConfig->fileName; |
Input |
|
Return |
|
new
Constructs a new config file object. By default, key and section names are case insensitive.
Syntax |
$IniConfig = DE_EPAGES::Core::API::IniConfig->new( FileName => $FileName, CaseSensitive => $CaseSensitive, Create => $Create, flock => $flock, ); |
Example |
$IniConfig = DE_EPAGES::Core::API::IniConfig->new( FileName => 'win.ini' ); |
Input |
|
Return |
|
read
Reads the configuration file in the windows ini file format.
Syntax |
$IniConfig->read( $FileName ); |
Example |
$IniConfig->read( 'database.ini' ); |
Input |
|
section
Returns the specified section with key-value pairs as a hash reference or creates a section with the new hash. Returns an empty hash reference if the section does not exist.
Syntax |
$hSection = $IniConfig->section( $Section ); $hSection = $IniConfig->section( $Section, $hSection ); |
Example |
$hDatabase = $IniConfig->section( 'Database' ); |
Input |
|
Return |
|
sectionNames
Returns all section names found in the config file.
Syntax |
$aSections = $IniConfig->sectionNames |
Return |
|
set
Sets a value in the config file. Calls $IniConfig->rewrite to make the changes persistent.
Syntax |
$IniConfig->set( $Section, $Key, $Value ); |
Example |
$IniConfig->set( 'Database', 'User', 'sa' ); |
Input |
|