|
Asterisk::config - the Asterisk config read and write module. |
Asterisk::config - the Asterisk config read and write module.
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);
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.
please use = instand of => in your config files.
my $rc = new Asterisk::config;
Instantiates a new object.
$rc->(filename=>[configfile],stream_data=>[strings]);
load config from file or from stream data.
$rc->assign_cleanfile();
be sure clean all data from current file.
$rc->assign_matchreplace(match=>,replace=>);
replace new data when matched.
$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.
up / down / foot with section.
$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.
$rc->assign_replacesection(section=>[section],
data=>[key=value,key=value]|{key=>value,key=>value}|'key=value'
);
replace the section body data,except ``#'' in body.
$rc->assign_delsection(section=>[section]);
erase section name and section data.
$rc->assign_addsection(section=>[section]);
add section with name.
$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
$rc->assign_delkey(section=>[section],key=>[keyname],value=>[value]);
erase all matched keyname in section or in [unsection].
$rc->save_file(filename=>[filename],resource=>[resource]);
process assign rules and save to file.
$rc->clean_assign();
clean all assign rules.
be come soon...
Asterisk::config by hoowa sun.
Version 0.7 patch by Liu Hailong.
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.
The Asterisk::config is free Open Source software.
IT COMES WITHOUT WARRANTY OF ANY KIND.
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. |