NAME

Libconf::Templates::Generic::KeyValues - Libconf generic low level template for semantic association (KEY - (KEY0 - VALUE0, ... KEYn - VALUEn)) styles config files

DESCRIPTION

Libconf::Templates::Generic::KeyValues is a generic template that handles config files that contain semantic informations of type : (KEY - (KEY0 - VALUE0, ... KEYn - VALUEn)).

SYNOPSIS

  my $template = new Libconf::Templates::Generic::KeyValues({
                                                             filename => 'some_file',
                                                             comments_struct => [['#']],
                                                             regexp => '^\s*(\S+?):(\S*?):(\S*?):(.*?)\s*$',
                                                             keys_list => [qw(group_name passwd GID user_list)],
                                                             identifier_key => 'group_name',
                                                             output_function => sub { join(':', map { $atom->{values}{$_} } @_ ) }
                                                           })
 $template->read_conf();
 ...
 (see L<Libconf::Templates> for transformation methods on $template)
 ...
 $template->write_conf();

CONSTRUCTOR

new($options)

creates the template

  $template = new Libconf::Templates::Generic::KeyValues({
                                                           filename => 'some_file',
                                                           comments_struct => [['#']],
                                                           regexp => '^\s*(\S+?):(\S*?):(\S*?):(.*?)\s*$',
                                                           keys_list => [qw(group_name passwd GID user_list)],
                                                           identifier_key => 'group_name',
                                                           output_function => sub { join(':', map { $atom->{values}{$_} } @_ ) }
                                                         })

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.

regexp [type : STRING, default : ''] : the regexp that is applied to each line

keys_list [type : ARRAY_REF, default : []] : the list of names of keys which will receive the regexp matchs

identifier_key [type : STRING, default : $key_list->[0] ] : the key that identifies line

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

keys_list [type : ARRAY_REF, default : []] : the list of names of keys which will receive the regexp matchs

output_function [type : FUNCTION_REF, default : sub {} ] : the code to be applied to an atom, to generate the line to output. It takes in arguments the atom, and the list of keys keys_list : ($atom, @key_list)

GENERAL METHODS

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

SPECIFIC METHODS

There is no specific methods