GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Config::IniRegEx(3) User Contributed Perl Documentation Config::IniRegEx(3)

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

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

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

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

        %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
                3

        %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 gmail.com>"

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.

Hey! The above document had some coding errors, which are explained below:
Around line 218:
=cut found outside a pod block. Skipping to next block.
2009-01-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.