7.2.6 Config - Access Perl Configuration Informationuse Config; if ($Config{cc} =~ /gcc/) { print "built by gcc\n"; } use Config qw(myconfig config_sh config_vars); print myconfig(); print config_sh(); config_vars(qw(osname archname)); The Config module contains all the information that the Configure script had to figure out at Perl build time (over 450 values).[ 7 ]
Shell variables from the
config.sh
file (written by
Configure
) are stored in a readonly hash,
Here's a more sophisticated example using use Config; defined $Config{sig_name} or die "No sigs?"; foreach $name (split(' ', $Config{sig_name})) { $signo{$name} = $i; $signame[$i] = $name; $i++; } print "signal #17 = $signame[17]\n"; if ($signo{ALRM}) { print "SIGALRM is $signo{ALRM}\n"; } Because configuration information is not stored within the Perl executable itself, it is possible (but unlikely) that the information might not relate to the actual Perl binary that is being used to access it. The Config module checks the Perl version number when loaded to try to prevent gross mismatches, but can't detect subsequent rebuilds of the same version. |
|