1General::Interpolated(3U)ser Contributed Perl DocumentatiGoenneral::Interpolated(3)
2
3
4

NAME

6       Config::General::Interpolated - Parse variables within Config files
7

SYNOPSIS

9        use Config::General;
10        $conf = Config::General->new(
11           -ConfigFile      => 'configfile',
12           -InterPolateVars => 1
13        );
14

DESCRIPTION

16       This is an internal module which makes it possible to interpolate Perl
17       style variables in your config file (i.e. $variable or "${variable}").
18
19       Normally you don't call it directly.
20

VARIABLES

22       Variables can be defined everywhere in the config and can be used
23       afterwards as the value of an option. Variables cannot be used as keys
24       or as part of keys.
25
26       If you define a variable inside a block or a named block then it is
27       only visible within this block or within blocks which are defined
28       inside this block. Well - let's take a look to an example:
29
30        # sample config which uses variables
31        basedir   = /opt/ora
32        user      = t_space
33        sys       = unix
34        <table intern>
35            instance  = INTERN
36            owner     = $user                 # "t_space"
37            logdir    = $basedir/log          # "/opt/ora/log"
38            sys       = macos
39            <procs>
40                misc1   = ${sys}_${instance}  # macos_INTERN
41                misc2   = $user               # "t_space"
42            </procs>
43        </table>
44
45       This will result in the following structure:
46
47        {
48            'basedir' => '/opt/ora',
49            'user'    => 't_space'
50            'sys'     => 'unix',
51            'table'   => {
52                 'intern' => {
53                       'sys'      => 'macos',
54                       'logdir'   => '/opt/ora/log',
55                       'instance' => 'INTERN',
56                       'owner' => 't_space',
57                       'procs' => {
58                            'misc1' => 'macos_INTERN',
59                            'misc2' => 't_space'
60                   }
61                }
62            }
63
64       As you can see, the variable sys has been defined twice. Inside the
65       <procs> block a variable ${sys} has been used, which then were
66       interpolated into the value of sys defined inside the <table> block,
67       not the sys variable one level above. If sys were not defined inside
68       the <table> block then the "global" variable sys would have been used
69       instead with the value of "unix".
70
71       Variables inside double quotes will be interpolated, but variables
72       inside single quotes will not interpolated. This is the same behavior
73       as you know of Perl itself.
74
75       In addition you can surround variable names with curly braces to avoid
76       misinterpretation by the parser.
77

NAMING CONVENTIONS

79       Variable names must:
80
81       •   start with a US-ASCII letter(a-z or A-Z) or a digit (0-9).
82
83       •   contain only US-ASCII letter(a-z or A-Z), digits (0-9), the dash
84           (-)
85                   colon (:), dot (.), underscore (_) and plus (+) characters.
86
87       For added clarity variable names can be surrounded by curly braces.
88

SEE ALSO

90       Config::General
91

AUTHORS

93        Thomas Linden <tlinden |AT| cpan.org>
94        Autrijus Tang <autrijus@autrijus.org>
95        Wei-Hon Chen <plasmaball@pchome.com.tw>
96
98       Copyright 2001 by Wei-Hon Chen <plasmaball@pchome.com.tw>.  Copyright
99       2002-2022 by Thomas Linden <tlinden |AT| cpan.org>.
100
101       This program is free software; you can redistribute it and/or modify it
102       under the terms of the Artistic License 2.0.
103
104       See <http://www.perl.com/perl/misc/Artistic.html>
105

VERSION

107       2.16
108
109
110
111perl v5.36.0                      2022-07-22          General::Interpolated(3)
Impressum