Config#
Look up the build-time configuration of the running Perl interpreter.
Config exposes the values recorded when Perl itself was compiled - platform, compiler flags, install paths, feature toggles. Scripts consult it to make portability decisions, locate installed libraries, or report interpreter characteristics.
Two surfaces are provided:
The tied hash
%Config, accessed element-wise as$Config{key}. Lookup, existence, and iteration go through the tie hooks. The hash is read-only;STORE,DELETE, andCLEARcroak.Programmatic queries:
config_re,config_sh,config_vars,myconfig,compile_date,bincompat_options,non_bincompat_options,local_patches,header_files, and theperl -Vbackend_V.
Under pperl, every value reflects pperl’s own build, not any upstream perl’s. Callers using %Config entries to drive portability decisions (compiler name, archname, install prefix, feature defines) get answers that match the interpreter they are actually running.
use Config;
printf "%s, IVs of %d bytes, threads %s\n",
$Config{archname}, $Config{ivsize}, $Config{useithreads} // 'no';
# x86_64-linux, IVs of 8 bytes, threads no
print "can fork\n" if $Config{d_fork};
eval { $Config{cc} = 'gcc' }; # dies: %Config::Config is read-only
print Config::myconfig(); # the summary perl -V prints
use Config exports %Config; myconfig, config_sh, config_vars, config_re and the other functions are imported by name. $Config::VERSION is the interpreter’s version, as $] is.
Differences from upstream#
The values describe pperl, as upstream’s describe the perl they were built with: version is 5.44.99, cc is rustc, and myconfig starts “Summary of pperl X.Y.Z (perl 5.44 compatible) configuration” with pperl’s own version. The keys that describe a C toolchain (cppstdin, d_attribute_format, libsfound, …) are empty or undef: pperl’s build has none. The keys, the functions and the read-only tied hash are upstream’s. Three functions are pperl’s own: Config::lib_file says under which path the interpreter sees a library file, the files inside the binary included, Config::lib_files lists the files inside the binary, and Config::jit_counts says how much the JIT has compiled. Every key perl 5.44’s %Config has is here; build.rs derives the bulk of them at build time (src/build_configure.rs).
Modules#
Config::Extensions- hash lookup of which core extensions were built.
Functions#
Querying#
myconfig#
Return a human-readable summary of the interpreter’s build.
config_sh#
Return the full configuration as one shell-assignment block.
config_vars#
Print selected configuration entries to STDOUT.
config_re#
Grep configuration entries whose key matches a pattern.
Introspection#
lib_file#
Say under which path this interpreter sees a library file.
lib_files#
jit_counts#
compile_date#
Return a one-line description of when and with what the interpreter was built.
local_patches#
Return the list of local patches applied to the interpreter.
bincompat_options#
Return the compile-time options that affect binary compatibility.
non_bincompat_options#
Return compile-time options that do not affect binary compatibility.
header_files#
Return the canonical list of Perl C header filenames.