info > Config::General::Interpolated

General::Interpolated(User Contributed Perl DocumentGeneral::Interpolated(3pm)

📛 NAME

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

🚀 Quick Reference

Use CaseCommandDescription
Enable variable interpolationConfig::General->new(-ConfigFile => 'file', -InterPolateVars => 1)Parse config file with Perl-style variable interpolation.
Define a variablebasedir = /opt/oraAssign a value to a variable.
Use a variablelogdir = $basedir/logInterpolate variable using $varname.
Use variable with bracesmisc1 = ${sys}_${instance}Avoid ambiguity by surrounding variable name with {}.
Prevent interpolationvalue = '$var'Variables inside single quotes are not interpolated.
Variable scoping in blocks<block> ... </block>Variables defined in a block are only visible within that block.

📋 SYNOPSIS

use Config::General;
$conf = Config::General->new(
   -ConfigFile      => 'configfile',
   -InterPolateVars => 1
);

📝 DESCRIPTION

This is an internal module which makes it possible to interpolate Perl style variables in your config file (i.e. $variable or ${variable}).

Normally you don't call it directly.

🧩 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.

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:

# sample config which uses variables
basedir   = /opt/ora
user      = t_space
sys       = unix
<table intern>
    instance  = INTERN
    owner     = $user                 # "t_space"
    logdir    = $basedir/log          # "/opt/ora/log"
    sys       = macos
    <procs>
        misc1   = ${sys}_${instance}  # macos_INTERN
        misc2   = $user               # "t_space"
    </procs>
</table>

This will result in the following structure:

{
    'basedir' => '/opt/ora',
    'user'    => 't_space'
    'sys'     => 'unix',
    'table'   => {
         'intern' => {
               'sys'      => 'macos',
               'logdir'   => '/opt/ora/log',
               'instance' => 'INTERN',
               'owner' => 't_space',
               'procs' => {
                    'misc1' => 'macos_INTERN',
                    'misc2' => 't_space'
           }
        }
    }
}

As you can see, the variable sys has been defined twice. Inside the <procs> block a variable ${sys} has been used, which then were interpolated into the value of sys defined inside the <table> block, not the sys variable one level above. If sys were not defined inside the <table> block then the "global" variable sys would have been used instead with the value of "unix".

Variables inside double quotes will be interpolated, but variables inside single quotes will not interpolated. This is the same behavior as you know of Perl itself.

In addition you can surround variable names with curly braces to avoid misinterpretation by the parser.

🔗 SEE ALSO

Config::General

👤 AUTHORS

ÂŠī¸ COPYRIGHT

Copyright 2001 by Wei-Hon Chen <plasmaball AT pchome.tw>. Copyright 2002-2014 by Thomas Linden <tlinden |AT| cpan.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

đŸ”ĸ VERSION

2.15

perl v5.22.2 2016-07-31 General::Interpolated(3pm)

Config::General::Interpolated
📛 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION 🧩 VARIABLES 🔗 SEE ALSO 👤 AUTHORS ÂŠī¸ COPYRIGHT đŸ”ĸ VERSION

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-24 07:53 @216.73.216.102
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!