View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
sasi > Config-IniRegEx > Config::IniRegEx



Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  


Config::IniRegEx - Ini workaround, regex search for parameters and sections.


use Config::IniRegEx;

my $foo = Config::IniRegEx->New();

$foo->ValRegex('section_name', 'parameter_regex');





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.


The following functions are available.


        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] );

                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");


        %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


        @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' )


        $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


        %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


Sasi, <sasi.asterisk at>


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.

syntax highlighting: