Libconf::Templates::Generic::Sections - Libconf generic low level template for semantic association (SECTION) rules
Libconf::Templates::Generic::Sections is a generic template that handles config files that contain semantic informations of type : (SECTION).
$template = new Libconf::Templates::Generic::Section({ section_regexp => '^\s*\[([^\]]+)\]\s*$', section_output_function => sub { "[$_->[0]]" }, has_endsection => 0, endsection_regexp => '', endsection_output_function => '', comments_struct => [['#']], }); $template->read_conf(); ... (see L<Libconf::Templates> for transformation methods on $template) ... ... $template->write_conf("output_file");
creates the template
$template = new Libconf::Templates::Generic::Section({ section_regexp => '^\s*\[([^\]]+)\]\s*$', section_output_function => sub { "[$_->[0]]" }, has_endsection => 0, endsection_regexp => '', endsection_output_function => '', comments_struct => [['#']], });
arguments
$options [type : HASH_REF] specifies the options to create the new template instance.
options
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.
comments_struct [type : ARRAY_REF of ARRAY_REF of STRING,STRING,SCALAR, default : [['#']] ] : defines the type and the characters of comments. See the Libconf::Templates::Keyvalue manpage for additional details on it
See the Libconf::Templates manpage for the general list of methods you can call on this template.
There is no specific method