NAME

Libconf::Templates::KeyValueSections - Libconf low level template for semantic (KEY - VALUE) and SECTION

DESCRIPTION

Libconf::Templates::KeyValueSections - Libconf low level template for semantic (KEY - VALUE) and SECTION

CONSTRUCTOR

new($options)

creates the template

my $template = new Libconf::Templates::KeyValueSections({
                                                          filename => '/etc/samba/smb.conf'
                                                          separator_char => '=',
                                                          allow_space => 1,
                                                          handle_quote => 0,
                                                          handle_multiples_lines => 0,
                                                          section_regexp => '^\s*\[([^\]]+)\]\s*$',
                                                          section_output_function => sub { "[$_[0]]" },
                                                          has_endsection => 0,
                                                          endsection_regexp => '',
                                                          endsection_output_function => '',
                                                        });

arguments

$options [type : HASH_REF] specifies the options to create the new template instance.

options

filename [type : STRING, default : ''] : the filename of the config file you want to work on. Can be read and written lately by using set_filename and get_filename.

comments_struct [type : ARRAY_REF of ARRAY_REF of STRING,STRING,SCALAR, default : [['#']] ] : defines the type and the characters of comments. See Libconf::Templates::Keyvalue for additional details on it

handle_quote [type : SCALAR, default : false] : if true, quotes are interpreted and removed from the value. When writing to the config file back, quotes are added if needed. if false, quotes are not interpreted, and present in the value.

handle_multiples_lines [type : BOOLEAN, default : false] : if true, line that begins with a space character and that doesn't contain the separator_char, are taken as the continuation of the upper line

accept_empty_value [type : BOOLEAN, default : true] : if true, lines where the value is not specified (like ``key='') are accepted, and the value is set to empty string. If set to false, such a line will trigger an error.

separator_char [type : STRING, default : '='] : the separator between key and value

allow_spaces [type : SCALAR, default : 1] : if true, space around separator_char are allowed and ignored if false, they are not allowed.

section_regexp [type : STRING, default : '^\s*\[([^\]]+)\]\s*$'] : the regexp that is applied to determine if a line is a section start. $1 has to be the section name.

section_output_function [type : FUNCTION_REF, default : sub { "[$_->[0]]" } ] : the code to be applied to a section atom, to generate the line to output. It takes in arguments the name of the section, the atom structure, and $parser_env, the parser environment variable. It should return the line to be written

has_endsection [type : BOOLEAN, default : 1] : if true, section have both start and end tag. If false, a section is considered to end where another section begins, or at the end of the file

endsection_output_function [type : FUNCTION_REF, default : sub { '' } ] : the code to be applied to a section atom, to generate the end section line to output. It takes in arguments the name of the section, the atom structure, and $parser_env, the parser environment variable. It should return the line to be written

endsection_regexp [type : STRING, default : ''] : the regexp that is applied to determine if a line is a end of a section.

GENERAL METHODS

See Libconf::Templates for the general list of methods you can call on this template.

SPECIFIC METHODS

There is no specific methods