1Config::Model::Backend:U:sPeerrlCFoinlter(i3b)uted PerlCDooncfuimge:n:tMaotdieoln::Backend::PerlFile(3)
2
3
4

NAME

6       Config::Model::Backend::PerlFile - Read and write config as a Perl data
7       structure
8

VERSION

10       version 2.140
11

SYNOPSIS

13        use Config::Model ;
14        use Data::Dumper ;
15
16        # define configuration tree object
17        my $model = Config::Model->new ;
18        $model ->create_config_class (
19           name => "MyClass",
20           element => [
21               [qw/foo bar/] => {
22                   type => 'leaf',
23                   value_type => 'string'
24               },
25               baz => {
26                   type => 'hash',
27                   index_type => 'string' ,
28                   cargo => {
29                       type => 'leaf',
30                       value_type => 'string',
31                   },
32               },
33           ],
34         rw_config  => {
35            backend => 'perl_file' ,
36            config_dir => '/tmp',
37            file  => 'foo.pl',
38            auto_create => 1,
39         },
40        ) ;
41
42        my $inst = $model->instance(root_class_name => 'MyClass' );
43
44        my $root = $inst->config_root ;
45
46        my $steps = 'foo=yada bar="bla bla" baz:en=hello
47                    baz:fr=bonjour baz:hr="dobar dan"';
48        $root->load( steps => $steps ) ;
49        $inst->write_back ;
50
51       Now, "/tmp/foo.pl" contains:
52
53        {
54          bar => 'bla bla',
55          baz => {
56            en => 'hello',
57            fr => 'bonjour',
58            hr => 'dobar dan'
59          },
60          foo => 'yada'
61        }
62

DESCRIPTION

64       This module is used directly by Config::Model to read or write the
65       content of a configuration tree written with Perl syntax in
66       "Config::Model" configuration tree.
67
68       Note:
69
70       ·   Undefined values are skipped for list element. I.e. if a list
71           element contains "('a',undef,'b')", the data structure contains
72           'a','b'.
73
74       ·   Perl file is not created (and may be deleted) when no data is to be
75           written.
76

backend parameter

78   config_dir
79       Mandoatory parameter to specify where is the Perl configuration file.
80

CONSTRUCTOR

82   new
83       Inherited from Config::Model::Backend::Any. The constructor is called
84       by Config::Model::BackendMgr.
85
86   read
87       Of all parameters passed to this read call-back, only "ifile_path" is
88       used. This parameter must be IO::File object already opened for read.
89
90       It can also be undef. In which case "read" returns 0.
91
92       When a file is read, "read" returns 1.
93
94   write
95       Of all parameters passed to this write call-back, only "file_path" is
96       used. This parameter must be a Path::Tiny object.
97
98       "write" returns 1.
99

AUTHOR

101       Dominique Dumont, (ddumont at cpan dot org)
102

SEE ALSO

104       Config::Model, Config::Model::BackendMgr, Config::Model::Backend::Any,
105

AUTHOR

107       Dominique Dumont
108
110       This software is Copyright (c) 2005-2020 by Dominique Dumont.
111
112       This is free software, licensed under:
113
114         The GNU Lesser General Public License, Version 2.1, February 1999
115
116
117
118perl v5.32.0                      2020-08-02Config::Model::Backend::PerlFile(3)
Impressum