|
Config - access Perl configuration information
use Config;
if ($Config{usethreads}) {
print "has thread support\n"
}
use Config qw(myconfig config_sh config_vars config_re);
print myconfig();
print config_sh();
print config_re();
config_vars(qw(osname archname));
The Config module contains all the information that was available to
the Configure program at Perl build time (over 900 values).
Shell variables from the config.sh file (written by Configure) are
stored in the readonly-variable %Config, indexed by their names.
Values stored in config.sh as 'undef' are returned as undefined
values. The perl exists function can be used to check if a
named variable exists.
myconfig()
-
Returns a textual summary of the major perl configuration values.
See also -V in Switches in the perlrun manpage.
config_sh()
-
Returns the entire perl configuration information in the form of the
original config.sh shell variable assignment script.
config_re($regex)
-
Like config_sh() but returns, as a list, only the config entries who's
names match the $regex.
config_vars(@names)
-
Prints to STDOUT the values of the named configuration variable. Each is
printed on a separate line in the form:
-
name='value';
-
Names which are unknown are output as name='UNKNOWN';.
See also -V:name in Switches in the perlrun manpage.
Here's a more sophisticated example of using %Config:
use Config;
use strict;
my %sig_num;
my @sig_name;
unless($Config{sig_name} && $Config{sig_num}) {
die "No sigs?";
} else {
my @names = split ' ', $Config{sig_name};
@sig_num{@names} = split ' ', $Config{sig_num};
foreach (@names) {
$sig_name[$sig_num{$_}] ||= $_;
}
}
print "signal #17 = $sig_name[17]\n";
if ($sig_num{ALRM}) {
print "SIGALRM is $sig_num{ALRM}\n";
}
Because this information is not stored within the perl executable
itself it is possible (but unlikely) that the information does not
relate to the actual perl binary which is being used to access it.
The Config module is installed into the architecture and version
specific library directory ($Config{installarchlib}) and it checks the
perl version number when loaded.
The values stored in config.sh may be either single-quoted or
double-quoted. Double-quoted strings are handy for those cases where you
need to include escape sequences in the strings. To avoid runtime variable
interpolation, any $ and @ characters are replaced by \$ and
\@, respectively. This isn't foolproof, of course, so don't embed \$
or \@ in double-quoted strings unless you're willing to deal with the
consequences. (The slashes will end up escaped and the $ or @ will
trigger variable interpolation)
Most Config variables are determined by the Configure script
on platforms supported by it (which is most UNIX platforms). Some
platforms have custom-made Config variables, and may thus not have
some of the variables described below, or may have extraneous variables
specific to that particular port. See the port specific documentation
in such cases.
_a
-
From Unix.U:
-
This variable defines the extension used for ordinary library files.
For unix, it is .a. The . is included. Other possible
values include .lib.
_exe
-
From Unix.U:
-
This variable defines the extension used for executable files.
DJGPP, Cygwin and OS/2 use .exe. Stratus VOS uses .pm.
On operating systems which do not require a specific extension
for executable files, this variable is empty.
_o
-
From Unix.U:
-
This variable defines the extension used for object files.
For unix, it is .o. The . is included. Other possible
values include .obj.
afs
-
From afs.U:
-
This variable is set to true if AFS (Andrew File System) is used
on the system, false otherwise. It is possible to override this
with a hint value or command line option, but you'd better know
what you are doing.
afsroot
-
From afs.U:
-
This variable is by default set to /afs. In the unlikely case
this is not the correct root, it is possible to override this with
a hint value or command line option. This will be used in subsequent
tests for AFSness in the Perl configure and test process.
alignbytes
-
From alignbytes.U:
-
This variable holds the number of bytes required to align a
double-- or a long double when applicable. Usual values are
2, 4 and 8. The default is eight, for safety.
ansi2knr
-
From ansi2knr.U:
-
This variable is set if the user needs to run ansi2knr.
Currently, this is not supported, so we just abort.
aphostname
-
From d_gethname.U:
-
This variable contains the command which can be used to compute the
host name. The command is fully qualified by its absolute path, to make
it safe when used by a process with super-user privileges.
api_revision
-
From patchlevel.U:
-
The three variables, api_revision, api_version, and
api_subversion, specify the version of the oldest perl binary
compatible with the present perl. In a full version string
such as 5.6.1, api_revision is the 5.
Prior to 5.5.640, the format was a floating point number,
like 5.00563.
-
perl.c:incpush() and lib/lib.pm will automatically search in
$sitelib/.. for older directories back to the limit specified
by these api_ variables. This is only useful if you have a
perl library directory tree structured like the default one.
See INSTALL for how this works. The versioned site_perl
directory was introduced in 5.005, so that is the lowest
possible value. The version list appropriate for the current
system is determined in inc_version_list.U.
-
XXX To do: Since compatibility can depend on compile time
options (such as bincompat, longlong, etc.) it should
(perhaps) be set by Configure, but currently it isn't.
Currently, we read a hard-wired value from patchlevel.h.
Perhaps what we ought to do is take the hard-wired value from
patchlevel.h but then modify it if the current Configure
options warrant. patchlevel.h then would use an #ifdef guard.
api_subversion
-
From patchlevel.U:
-
The three variables, api_revision, api_version, and
api_subversion, specify the version of the oldest perl binary
compatible with the present perl. In a full version string
such as 5.6.1, api_subversion is the 1. See api_revision for
full details.
api_version
-
From patchlevel.U:
-
The three variables, api_revision, api_version, and
api_subversion, specify the version of the oldest perl binary
compatible with the present perl. In a full version string
such as 5.6.1, api_version is the 6. See api_revision for
full details. As a special case, 5.5.0 is rendered in the
old-style as 5.005. (In the 5.005_0x maintenance series,
this was the only versioned directory in $sitelib.)
api_versionstring
-
From patchlevel.U:
-
This variable combines api_revision, api_version, and
api_subversion in a format such as 5.6.1 (or 5_6_1) suitable
for use as a directory name. This is filesystem dependent.
ar
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the ar program. After Configure runs,
the value is reset to a plain ar and is not useful.
archlib
-
From archlib.U:
-
This variable holds the name of the directory in which the user wants
to put architecture-dependent public library files for $package.
It is most often a local directory such as /usr/local/lib.
Programs using this variable must be prepared to deal
with filename expansion.
archlibexp
-
From archlib.U:
-
This variable is the same as the archlib variable, but is
filename expanded at configuration time, for convenient use.
archname
-
From archname.U:
-
This variable is a short name to characterize the current
architecture. It is used mainly to construct the default archlib.
archname64
-
From use64bits.U:
-
This variable is used for the 64-bitness part of $archname.
archobjs
-
From Unix.U:
-
This variable defines any additional objects that must be linked
in with the program on this architecture. On unix, it is usually
empty. It is typically used to include emulations of unix calls
or other facilities. For perl on OS/2, for example, this would
include os2/os2.obj.
asctime_r_proto
-
From d_asctime_r.U:
-
This variable encodes the prototype of asctime_r.
It is zero if d_asctime_r is undef, and one of the
REENTRANT_PROTO_T_ABC macros of reentr.h if d_asctime_r
is defined.
awk
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the awk program. After Configure runs,
the value is reset to a plain awk and is not useful.
baserev
-
From baserev.U:
-
The base revision level of this package, from the .package file.
bash
-
From Loc.U:
-
This variable is defined but not used by Configure.
The value is a plain '' and is not useful.
bin
-
From bin.U:
-
This variable holds the name of the directory in which the user wants
to put publicly executable images for the package in question. It
is most often a local directory such as /usr/local/bin. Programs using
this variable must be prepared to deal with ~name substitution.
binexp
-
From bin.U:
-
This is the same as the bin variable, but is filename expanded at
configuration time, for use in your makefiles.
bison
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the bison program. After Configure runs,
the value is reset to a plain bison and is not useful.
byacc
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the byacc program. After Configure runs,
the value is reset to a plain byacc and is not useful.
byteorder
-
From byteorder.U:
-
This variable holds the byte order in a UV. In the following,
larger digits indicate more significance. The variable byteorder
is either 4321 on a big-endian machine, or 1234 on a little-endian,
or 87654321 on a Cray ... or 3412 with weird order !
c
-
From n.U:
-
This variable contains the \c string if that is what causes the echo
command to suppress newline. Otherwise it is null. Correct usage is
$echo $n "prompt for a question: $c".
castflags
-
From d_castneg.U:
-
This variable contains a flag that precise difficulties the
compiler has casting odd floating values to unsigned long:
0 = ok
1 = couldn't cast < 0
2 = couldn't cast >= 0x80000000
4 = couldn't cast in argument expression list
cat
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the cat program. After Configure runs,
the value is reset to a plain cat and is not useful.
cc
-
From cc.U:
-
This variable holds the name of a command to execute a C compiler which
can resolve multiple global references that happen to have the same
name. Usual values are cc and gcc.
Fervent ANSI compilers may be called c89. AIX has xlc.
cccdlflags
-
From dlsrc.U:
-
This variable contains any special flags that might need to be
passed with cc -c to compile modules to be used to create a shared
library that will be used for dynamic loading. For hpux, this
should be +z. It is up to the makefile to use it.
ccdlflags
-
From dlsrc.U:
-
This variable contains any special flags that might need to be
passed to cc to link with a shared library for dynamic loading.
It is up to the makefile to use it. For sunos 4.1, it should
be empty.
ccflags
-
From ccflags.U:
-
This variable contains any additional C compiler flags desired by
the user. It is up to the Makefile to use this.
ccflags_uselargefiles
-
From uselfs.U:
-
This variable contains the compiler flags needed by large file builds
and added to ccflags by hints files.
ccname
-
From Checkcc.U:
-
This can set either by hints files or by Configure. If using
gcc, this is gcc, and if not, usually equal to cc, unimpressive, no?
Some platforms, however, make good use of this by storing the
flavor of the C compiler being used here. For example if using
the Sun WorkShop suite, ccname will be workshop.
ccsymbols
-
From Cppsym.U:
-
The variable contains the symbols defined by the C compiler alone.
The symbols defined by cpp or by cc when it calls cpp are not in
this list, see cppsymbols and cppccsymbols.
The list is a space-separated list of symbol=value tokens.
ccversion
-
From Checkcc.U:
-
This can set either by hints files or by Configure. If using
a (non-gcc) vendor cc, this variable may contain a version for
the compiler.
cf_by
-
From cf_who.U:
-
Login name of the person who ran the Configure script and answered the
questions. This is used to tag both config.sh and config_h.SH.
cf_email
-
From cf_email.U:
-
Electronic mail address of the person who ran Configure. This can be
used by units that require the user's e-mail, like MailList.U.
cf_time
-
From cf_who.U:
-
Holds the output of the date command when the configuration file was
produced. This is used to tag both config.sh and config_h.SH.
chgrp
-
From Loc.U:
-
This variable is defined but not used by Configure.
The value is a plain '' and is not useful.
chmod
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the chmod program. After Configure runs,
the value is reset to a plain chmod and is not useful.
chown
-
From Loc.U:
-
This variable is defined but not used by Configure.
The value is a plain '' and is not useful.
clocktype
-
From d_times.U:
-
This variable holds the type returned by times(). It can be long,
or clock_t on BSD sites (in which case <sys/types.h> should be
included).
comm
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the comm program. After Configure runs,
the value is reset to a plain comm and is not useful.
compress
-
From Loc.U:
-
This variable is defined but not used by Configure.
The value is a plain '' and is not useful.
contains
-
From contains.U:
-
This variable holds the command to do a grep with a proper return
status. On most sane systems it is simply grep. On insane systems
it is a grep followed by a cat followed by a test. This variable
is primarily for the use of other Configure units.
cp
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the cp program. After Configure runs,
the value is reset to a plain cp and is not useful.
cpio
-
From Loc.U:
-
This variable is defined but not used by Configure.
The value is a plain '' and is not useful.
cpp
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the cpp program. After Configure runs,
the value is reset to a plain cpp and is not useful.
cpp_stuff
-
From cpp_stuff.U:
-
This variable contains an identification of the concatenation mechanism
used by the C preprocessor.
cppccsymbols
-
From Cppsym.U:
-
The variable contains the symbols defined by the C compiler
when it calls cpp. The symbols defined by the cc alone or cpp
alone are not in this list, see ccsymbols and cppsymbols.
The list is a space-separated list of symbol=value tokens.
cppflags
-
From ccflags.U:
-
This variable holds the flags that will be passed to the C pre-
processor. It is up to the Makefile to use it.
cpplast
-
From cppstdin.U:
-
This variable has the same functionality as cppminus, only it applies
to cpprun and not cppstdin.
cppminus
-
From cppstdin.U:
-
This variable contains the second part of the string which will invoke
the C preprocessor on the standard input and produce to standard
output. This variable will have the value - if cppstdin needs
a minus to specify standard input, otherwise the value is "".
cpprun
-
From cppstdin.U:
-
This variable contains the command which will invoke a C preprocessor
on standard input and put the output to stdout. It is guaranteed not
to be a wrapper and may be a null string if no preprocessor can be
made directly available. This preprocessor might be different from the
one used by the C compiler. Don't forget to append cpplast after the
preprocessor options.
cppstdin
-
From cppstdin.U:
-
This variable contains the command which will invoke the C
preprocessor on standard input and put the output to stdout.
It is primarily used by other Configure units that ask about
preprocessor symbols.
cppsymbols
-
From Cppsym.U:
-
The variable contains the symbols defined by the C preprocessor
alone. The symbols defined by cc or by cc when it calls cpp are
not in this list, see ccsymbols and cppccsymbols.
The list is a space-separated list of symbol=value tokens.
crypt_r_proto
-
From d_crypt_r.U:
-
This variable encodes the prototype of crypt_r.
It is zero if d_crypt_r is undef, and one of the
REENTRANT_PROTO_T_ABC macros of reentr.h if d_crypt_r
is defined.
cryptlib
-
From d_crypt.U:
-
This variable holds -lcrypt or the path to a libcrypt.a archive if
the crypt() function is not defined in the standard C library. It is
up to the Makefile to use this.
csh
-
From Loc.U:
-
This variable is used internally by Configure to determine the
full pathname (if any) of the csh program. After Configure runs,
the value is reset to a plain csh and is not useful.
ctermid_r_proto
-
From d_ctermid_r.U:
-
This variable encodes the prototype of ctermid_r.
It is zero if d_ctermid_r is undef, and one of the
REENTRANT_PROTO_T_ABC macros of reentr.h if d_ctermid_r
is defined.
ctime_r_proto
-
From d_ctime_r.U:
-
This variable encodes the prototype of ctime_r.
It is zero if d_ctime_r is undef, and one of the
REENTRANT_PROTO_T_ABC macros of reentr.h if d_ctime_r
is defined.
d__fwalk
-
From d__fwalk.U:
-
This variable conditionally defines HAS__FWALK if _fwalk() is
available to apply a function to all the file handles.
d_access
-
From d_access.U:
-
This variable conditionally defines HAS_ACCESS if the access() system
call is available to check for access permissions using real IDs.
d_accessx
-
From d_accessx.U:
-
This variable conditionally defines the HAS_ACCESSX symbol, which
indicates to the C program that the accessx() routine is available.
d_aintl
-
From d_aintl.U:
-
This variable conditionally defines the HAS_AINTL symbol, which
indicates to the C program that the aintl() routine is available.
If copysignl is also present we can emulate modfl.
d_alarm
-
From d_alarm.U:
-
This variable conditionally defines the HAS_ALARM symbol, which
indicates to the C program that the alarm() routine is available.
d_archlib
-
From archlib.U:
-
This variable conditionally defines ARCHLIB to hold the pathname
of architecture-dependent library files for $package. If
$archlib is the same as $privlib, then this is set to undef.
d_asctime_r
-
From d_asctime_r.U:
-
This variable conditionally defines the HAS_ASCTIME_R symbol,
which indicates to the C program that the asctime_r()
routine is available.
d_atolf
-
From atolf.U:
-
This variable conditionally defines the HAS_ATOLF symbol, which
indicates to the C program that the atolf() routine is available.
d_atoll
-
From atoll.U:
-
This variable conditionally defines the HAS_ATOLL symbol, which
indicates to the C program that the atoll() routine is available.
d_attribute_format
-
From d_attribut.U:
-
This variable conditionally defines HASATTRIBUTE_FORMAT, which
indicates the C compiler can check for printf-like formats.
d_attribute_malloc
-
From d_attribut.U:
-
This variable conditionally defines HASATTRIBUTE_MALLOC, which
indicates the C compiler can understand functions as having
malloc-like semantics.
d_attribute_nonnull
-
From d_attribut.U:
-
This variable conditionally defines HASATTRIBUTE_NONNULL, which
indicates that the C compiler can know that certain arguments
must not be NULL, and will check accordingly at compile time.
d_attribute_noreturn
-
From d_attribut.U:
-
This variable conditionally defines HASATTRIBUTE_NORETURN, which
indicates that the C compiler can know that certain functions
are guaranteed never to return.
d_attribute_pure
-
From d_attribut.U:
-
This variable conditionally defines HASATTRIBUTE_PURE, which
indicates that the C compiler can know that certain functions
are pure functions, meaning that they have no side effects, and
only rely on function input and/or global data for their results.
d_attribute_unused
-
From d_attribut.U:
-
This variable conditionally defines HASATTRIBUTE_UNUSED, which
indicates that the C compiler can know that certain variables
and arguments may not always be used, and to not throw warnings
if they don't get used.
d_attribute_warn_unused_result
-
From d_attribut.U:
-
This variable conditionally defines
HASATTRIBUTE_WARN_UNUSED_RESULT, which indicates that the C
compiler can know that certain functions have a return values
that must not be ignored, such as malloc() or open().
d_bcmp
-
From d_bcmp.U:
-
This variable conditionally defines the HAS_BCMP symbol if
the bcmp() routine is available to compare strings.
d_bcopy
-
From d_bcopy.U:
-
This variable conditionally defines the HAS_BCOPY symbol if
the bcopy() routine is available to copy strings.
d_bsd
-
From Guess.U:
-
This symbol conditionally defines the symbol BSD when running on a
BSD system.
d_bsdgetpgrp
-
From d_getpgrp.U:
-
This variable conditionally defines USE_BSD_GETPGRP if
getpgrp needs one arguments whereas USG one needs none.
d_bsdsetpgrp
-
From d_setpgrp.U:
-
This variable conditionally defines USE_BSD_SETPGRP if
setpgrp needs two arguments whereas USG one needs none.
See also d_setpgid for a POSIX interface.
d_builtin_choose_expr
-
From d_builtin.U:
-
This conditionally defines HAS_BUILTIN_CHOOSE_EXPR, which
indicates that the compiler supports __builtin_choose_expr(x,y,z).
This built-in function is analogous to the x?y:z operator in C,
except that the expression returned has its type unaltered by
promotion rules. Also, the built-in function does not evaluate
the expression that was not chosen.
d_builtin_expect
-
From d_builtin.U:
-
This conditionally defines HAS_BUILTIN_EXPECT, which indicates
that the compiler supports __builtin_expect(exp,c). You may use
__builtin_expect to provide the compiler with branch prediction
information.
d_bzero
-
From d_bzero.U:
-
This variable conditionally defines the HAS_BZERO symbol if
the bzero() routine is available to set memory to 0.
d_c99_variadic_macros
-
From d_c99_variadic.U:
-
This variable conditionally defines the HAS_C99_VARIADIC_MACROS
symbol, which indicates to the C program that C99 variadic macros
are available.
d_casti32
-
From d_casti32.U:
-
This variable conditionally defines CASTI32, which indicates
whether the C compiler can cast large floats to 32-bit ints.
d_castneg
-
From d_castneg.U:
-
This variable conditionally defines CASTNEG, which indicates
wether the C compiler can cast negative float to unsigned.
d_charvspr
-
From d_vprintf.U:
-
This variable conditionally defines CHARVSPRINTF if this system
has vsprintf returning type (char*). The trend seems to be to
declare it as "int vsprintf()".
d_chown
-
From d_chown.U:
-
This variable conditionally defines the HAS_CHOWN symbol, which
indicates to the C program that the chown() routine is available.
d_chroot
-
From d_chroot.U:
-
This variable conditionally defines the HAS_CHROOT symbol, which
indicates to the C program that the chroot() routine is available.
d_chsize
-
From d_chsize.U:
-
This variable conditionally defines the CHSIZE symbol, which
indicates to the C program that the chsize() routine is available
to truncate files. You might need a -lx to get this routine.
d_class
-
From d_class.U:
-
This variable conditionally defines the HAS_CLASS symbol, which
indicates to the C program that the class() routine is available.
d_clearenv
-
From d_clearenv.U:
-
This variable conditionally defines the HAS_CLEARENV symbol, which
indicates to the C program that the clearenv () routine is available.
d_closedir
-
From d_closedir.U:
-
This variable conditionally defines HAS_CLOSEDIR if closedir() is
available.
d_cmsghdr_s
-
From d_cmsghdr_s.U:
-
This variable conditionally defines the HAS_STRUCT_CMSGHDR symbol,
which indicates that the struct cmsghdr is supported.
d_const
-
From d_const.U:
-
This variable conditionally defines the HASCONST symbol, which
indicates to the C program that this C compiler knows about the
const type.
d_copysignl
-
From d_copysignl.U:
-
This variable conditionally defines the HAS_COPYSIGNL symbol, which
indicates to the C program that the copysignl() routine is available.
If aintl is also present we can emulate modfl.
d_cplusplus
-
From d_cplusplus.U:
-
This variable conditionally defines the USE_CPLUSPLUS symbol, which
indicates that a C++ compiler was used to compiled Perl and will be
used to compile extensions.
d_crypt
-
From d_crypt.U:
-
This variable conditionally defines the CRYPT symbol, which
indicates to the C program that the crypt() routine is available
to encrypt passwords and the like.
d_crypt_r
-
From d_crypt_r.U:
-
This variable conditionally defines the HAS_CRYPT_R symbol,
which indicates to the C program that the crypt_r()
routine is available.
d_csh
-
From d_csh.U:
-
This variable conditionally defines the CSH symbol, which
indicates to the C program that the C-shell exists.
d_ctermid
-
From d_ctermid.U:
-
This variable conditionally defines CTERMID if ctermid() is
available to generate filename for terminal.
d_ctermid_r
-
From d_ctermid_r.U:
-
This variable conditionally defines the HAS_CTERMID_R symbol,
which indicates to the C program that the ctermid_r()
routine is available.
d_ctime_r
-
From d_ctime_r.U:
-
This variable conditionally defines the HAS_CTIME_R symbol,
which indicates to the C program that the ctime_r()
routine is available.
d_cuserid
-
From d_cuserid.U:
-
This variable conditionally defines the HAS_CUSERID symbol, which
indicates to the C program that the cuserid() ro |