config_vars#
Print selected configuration entries to STDOUT.
Synopsis#
use Config;
Config::config_vars(qw(archname osname ivsize));
What you get back#
Nothing. Each named key is written to STDOUT on its own line as key='value';. Unknown keys render as key='UNKNOWN';, keys whose recorded value is undef as key='undef';. This is the backend of the -V:key command-line switch (see perlrun), including its query syntax: a leading : suppresses the key= tag, a trailing : ends the line with a space instead of ;\n, and a query containing non-word characters is treated as a regex and answered from config_re.
Examples#
use Config;
Config::config_vars('archname'); # archname='x86_64-linux';
Config::config_vars('archname', 'osname'); # two lines
Config::config_vars('ivsize|nvsize'); # regex: both entries
Config::config_vars(':archname'); # 'x86_64-linux'; (no tag)
Edge cases#
Unknown keys print
'UNKNOWN'; undef values print'undef'.Regex queries with no match print
pattern: not found.Output goes straight to the OS
STDOUT; redirecting withlocal *STDOUTin Perl does not affect it.
Differences from upstream#
Regex queries share
config_re’s pattern approximation (seeconfig_re“Differences from upstream”).