Libconf::Glueconf - Libconf high level common module
Libconf::Glueconf is a class that represents a config file at a high level. It provides an easy to use and powerful structure to edit the config file.
This is the high level layer of libconf. You should use it to read/write the informations to the config files. Here are some examples, but you should look in the specific modules below for more examples.
use Libconf::Glueconf::Samba::Smb_conf; my $samba = new Libconf::Glueconf::Samba::Smb_conf('/etc/samba/smb.conf'); $samba->{homes}->{writable} = 'TEST'; $samba->{global}->{workgroup} eq 'WORKGROUP' or die "workgroup is not correct\n"; $samba->write_conf();
use Libconf::Glueconf::X::XF86Config; use Data::Dumper; $Data::Dumper::Deepcopy = 1; $Data::Dumper::Quotekeys = 0; my $xorg = new Libconf::Glueconf::X::XF86Config('/etc/X11/xorg.conf'); print Dumper($xorg) . "\n";
See their documentation for specific methods
use Data::Dumper; my $structure = new Libconf::Glueconf::Some::Module; $structure->read_conf(); print Dumper($structure) . "\n";
description
This method reads the config file, and maps it to the structure. It doesn't use any argument for its own use, but you can give it arguments, they will be passed to the underlying Libconf::Templates::read_conf().
my $structure = new Libconf::Glueconf::Some::Module; $structure->read_conf(); ... edit $structure ... $structure->write_conf();
description
This method writes the structure back to the config file. It doesn't use any argument for its own use, but you can give it arguments, they will be passed to the underlying Libconf::Templates::write_conf().
$template->toXMLString();
description
toXMLString exports the template informations into an XML string.
The optional $format parameter sets the indenting of the output.
$template->toXMLFile('xml_filename');
description
toXMLFile exports the template informations into an XML file.
The optional $format parameter sets the indenting of the output.
$template->fromXMLFile('file.xml');
description
fromXMLFile imports the data from an XML file previously generated by toXMLFile
get the comments of an atom, described by the structure.
example
$comments = $samba->get_comments('{global}{workgroup}')
set the comments of an atom, described by the structure.
example
$samba->set_comments('{global}{workgroup}', $comments)
change the status of the atom to be commented or uncommented. A commented line will output commented with the first comment of $self->{comment_struct}
example
$samba->set_commented('{global}{workgroup}', 1)
when outputed, the line will be something like : # workgroup=foo;
returns the comment status of the atom.
example
if ($samba->commented('{global}{workgroup}'))
{
...
}