.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "General::Interpolated 3pm" .TH General::Interpolated 3pm "2022-10-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Config::General::Interpolated \- Parse variables within Config files .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& use Config::General; \& $conf = Config::General\->new( \& \-ConfigFile => \*(Aqconfigfile\*(Aq, \& \-InterPolateVars => 1 \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is an internal module which makes it possible to interpolate Perl style variables in your config file (i.e. \f(CW$variable\fR or \f(CW\*(C`${variable}\*(C'\fR). .PP Normally you don't call it directly. .SH "VARIABLES" .IX Header "VARIABLES" Variables can be defined everywhere in the config and can be used afterwards as the value of an option. Variables cannot be used as keys or as part of keys. .PP If you define a variable inside a block or a named block then it is only visible within this block or within blocks which are defined inside this block. Well \- let's take a look to an example: .PP .Vb 10 \& # sample config which uses variables \& basedir = /opt/ora \& user = t_space \& sys = unix \& \& instance = INTERN \& owner = $user # "t_space" \& logdir = $basedir/log # "/opt/ora/log" \& sys = macos \& \& misc1 = ${sys}_${instance} # macos_INTERN \& misc2 = $user # "t_space" \& \&
.Ve .PP This will result in the following structure: .PP .Vb 10 \& { \& \*(Aqbasedir\*(Aq => \*(Aq/opt/ora\*(Aq, \& \*(Aquser\*(Aq => \*(Aqt_space\*(Aq \& \*(Aqsys\*(Aq => \*(Aqunix\*(Aq, \& \*(Aqtable\*(Aq => { \& \*(Aqintern\*(Aq => { \& \*(Aqsys\*(Aq => \*(Aqmacos\*(Aq, \& \*(Aqlogdir\*(Aq => \*(Aq/opt/ora/log\*(Aq, \& \*(Aqinstance\*(Aq => \*(AqINTERN\*(Aq, \& \*(Aqowner\*(Aq => \*(Aqt_space\*(Aq, \& \*(Aqprocs\*(Aq => { \& \*(Aqmisc1\*(Aq => \*(Aqmacos_INTERN\*(Aq, \& \*(Aqmisc2\*(Aq => \*(Aqt_space\*(Aq \& } \& } \& } .Ve .PP As you can see, the variable \fBsys\fR has been defined twice. Inside the block a variable ${sys} has been used, which then were interpolated into the value of \fBsys\fR defined inside the block, not the sys variable one level above. If sys were not defined inside the
block then the \*(L"global\*(R" variable \fBsys\fR would have been used instead with the value of \*(L"unix\*(R". .PP Variables inside double quotes will be interpolated, but variables inside single quotes will \fBnot\fR interpolated. This is the same behavior as you know of Perl itself. .PP In addition you can surround variable names with curly braces to avoid misinterpretation by the parser. .SH "NAMING CONVENTIONS" .IX Header "NAMING CONVENTIONS" Variable names must: .IP "\(bu" 4 start with a US-ASCII letter(a\-z or A\-Z) or a digit (0\-9). .IP "\(bu" 4 contain only US-ASCII letter(a\-z or A\-Z), digits (0\-9), the dash (\-) colon (:), dot (.), underscore (_) and plus (+) characters. .PP For added clarity variable names can be surrounded by curly braces. .SH "SEE ALSO" .IX Header "SEE ALSO" Config::General .SH "AUTHORS" .IX Header "AUTHORS" .Vb 3 \& Thomas Linden \& Autrijus Tang \& Wei\-Hon Chen .Ve .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2001 by Wei-Hon Chen . Copyright 2002\-2022 by Thomas Linden . .PP This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. .PP See .SH "VERSION" .IX Header "VERSION" 2.16