NAME
Config::IniRegEx - Ini workaround, regex search for parameters and sections.
SYNOPSIS
use Config::IniRegEx;
my $foo = Config::IniRegEx->New();
$foo->ValRegex('section_name', 'parameter_regex');
$foo->SectionExistsRegex('section_regex');
$foo->SectionRegex('section_regex');
$foo->ParameterRegex('section_regex');
DESCRIPTION
Config::IniRegEx is dependent on Config::IniFiles. Using that module it does the ini configuration file parsing, with an addon facility of regex kind of search.
Each function explained below, searches for a different thing based up on the given regular expression. And it is a exact regex match.
When a function of a Config::IniFiles is called then it will be called using the autoload functionality, i.e all the functions of the Config::IniFiles can be called with this object itself. ( creating an object for Config::IniRegEx is enough, can access all the functions available at Config::IniFiles also. ).
This module aims out doing a regex search for Sections, and Parameters of the Ini configuration file. It does the Perl regex matching, nothing external. So whoever knows the Perl basic regex can use this feature.
FUNCTIONS
The following functions are available.
New
New (filename,nocase)
Returns a new configuration object (or "undef" if the configuration file has an error)
my $object = Config::IniRegEx->New('config_filename', [nocase] );
Arguments
First argument is absolute path of the ini configuration file which you want
to manipulate.
Second argument could be 0 or 1.
0 to handle the config file in a case-sensitive manner
1 to handle the config file in a case-insensitive manner
By default, config files are case-sensitive.
For Example
my $object = Config::IniRegEx->New("sample.ini");
ValRegex
%val_hash = $foo->ValRegex('section_name','parameter_regex');
section_name - should be text, ( not a regular expression )
parameter_regex - can be Perl regex
return's undef when
1. Section does not exist
2. Section exists, but no match for parameter.
else return's the matched set of parameter and its value as a hash.
For Example
%val_hash = $foo->ValRegex('sizes','size_._side');
%val_hash will contain
size_a_side => 100
size_b_side => 55
SectionRegex
@box_sections = $foo->SectionRegex('section_name_regex');
section_name_regex - regex to match section name
return's undef when
1. section argument is not given
2. section does not matches.
else return's an array of matched section names.
For Example
@box_sections = $foo->SectionRegex("box_.*");
@size_of_all_sides will contain
( 'box_day_first', 'box_day_second','box_day_third' )
SectionExistsRegex
$section_available = $foo->SectionExistsRegex('section_name_regex');
section_name_regex - regex to match section name
return's 0 when
1. When the section argument is not passed
2. when the section does not match
else return's number of match
For Example
$section_available = $foo->SectionExistsRegex('box_.*');
$section_available will contain
3
ParameterRegex
%matched_hash = $foo->ParameterRegex('section_name_regex');
section_name_regex - regex to match section name
returns undef. When
1. section argument is not given
2. when the section does not match
else returns hash of hash, where the hash key is section name, and the nested hash key is parameter name.
For Example
%matched_hash = $foo->ParameterRegex("box_day_.*");
%matched_hash will contain
( 'box_day_first' => {
'expected_from' => Tue,
'expected_to' => Thu
},
'box_day_second' => {
'expected_from' => Mon,
'expected_to' => Fri
},
'box_day_third' => {
'expected_from' => Mon,
'expected_to' => Sat
},
)
AUTHOR
Sasi, <sasi.asterisk at gmail.com>
COPYRIGHT & LICENSE
Copyright 2009 Sasi, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 218:
=cut found outside a pod block. Skipping to next block.