Asterisk::config - the Asterisk config read and write module.


NAME

Asterisk::config - the Asterisk config read and write module.


SYNOPSIS

        use Asterisk::config;
        my $rc = new Asterisk::config;
        my ($cfg,$res) = $rc->load_config(filename=>[configfile],stream_data=>[strings]);
        print $cfg->{'[unsection]'}{'test'}[0];
        print $cfg->{'[global]'}{'allow'}[1];
        $rc->assign_append(point=>'down',data=>$user_data);
        $rc->save_file(filename=>[filename],resource=>$res);


DESCRIPTION

Asterisk::config know how Asterisk config difference with standard ini config. this moudle make interface for read and write Asterisk config files and Asterisk extension configs.


NOTE

please use = instand of => in your config files.


METHOD

new

        my $rc = new Asterisk::config;

Instantiates a new object.

load_config

        $rc->(filename=>[configfile],stream_data=>[strings]);

load config from file or from stream data.

assign_cleanfile

        $rc->assign_cleanfile();

be sure clean all data from current file.

assign_matchreplace

        $rc->assign_matchreplace(match=>,replace=>);

replace new data when matched.

assign_append

        $rc->assign_append(point=>['up'|'down'|'foot'],
                section=>[section],
                data=>[key=value,key=value]|{key=>value,key=>value}|'key=value'
                );

append data around with section name.

        $rc->assign_append(point=>['up'|'down'|'over'],
                section=>[section],
                comkey=>[key,value],
                data=>[key=value,key=value]|{key=>value,key=>value}|'key=value'
                );

append data around with section name and key/value in same section.

        $rc->assign_append(point=>'up'|'down',
                data=>[key=value,key=value]|{key=>value,key=>value}|'key=value'
                );

simple append data without any section.

assign_replacesection

        $rc->assign_replacesection(section=>[section],
                data=>[key=value,key=value]|{key=>value,key=>value}|'key=value'
                );

replace the section body data,except ``#'' in body.

assign_delsection

        $rc->assign_delsection(section=>[section]);

erase section name and section data.

assign_addsection

        $rc->assign_addsection(section=>[section]);

add section with name.

assign_editkey

        $rc->assign_editkey(section=>[section],key=>[keyname],value=>[value],new_value=>[new_value]);

modify value with matched section.if don't assign value=> will replace all matched key.

exp script:

        $rc->assign_editkey(section=>'990001',key=>'all',new_value=>'gsm');

data:

        all=g711
        all=ilbc

will convert to:

        all=gsm
        all=gsm

assign_delkey

        $rc->assign_delkey(section=>[section],key=>[keyname],value=>[value]);

erase all matched keyname in section or in [unsection].

save_file

        $rc->save_file(filename=>[filename],resource=>[resource]);

process assign rules and save to file.

clean_assign

        $rc->clean_assign();

clean all assign rules.


EXAMPLES

be come soon...


AUTHORS

Asterisk::config by hoowa sun.

Version 0.7 patch by Liu Hailong.


COPYRIGHT

The Asterisk::config module is Copyright (c) 2005-2006 hoowa sun. P.R.China. All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.


WARRANTY

The Asterisk::config is free Open Source software.

IT COMES WITHOUT WARRANTY OF ANY KIND.


SUPPORT

Email(Chinese & English) hoowa.sun@gmail.com

Chinese OpenPBX technology Forum http://www.openpbx.cn

Chinese Perl Forum http://bbs.perlchina.org

 Asterisk::config - the Asterisk config read and write module.