Note that Config is not a module that reads configuration files, nor is it the base of the Config:: namespace, the latter being the CPAN modules that typically do read configuration files, like Config::Tiny.
Config is "all the information that was available to the Configure program at Perl build time ... Shell variables from the config.sh file (written by Configure) are stored in the readonly-variable %Config, indexed by their names." So in other words, it's the perl build configuration, which is fixed for each build of Perl at compile time.
The four functions (not methods) that you mention, myconfig, config_sh, config_vars, and config_re, are basically just alternate ways to get information out of Config. In the example code you showed, my $archname = $Config{'archname'}; does not work because you're only requesting those four functions to be exported from Config, but not the %Config hash. So you don't need to "import the values from the myconfig() method into a hash", that's %Config.
You can either just use the module in the basic fashion, where %Config is exported by default:
use Config; my $archname = $Config{'archname'}; print "<$archname>\n";
Or, if you do want to export functions from the module, you need to request the export of %Config explicitly:
use Config qw/%Config config_vars/; my $archname = $Config{'archname'}; print "<$archname>\n"; config_vars("archname","version");
In reply to Re: how to get Config values into a hash
by haukex
in thread how to get Config values into a hash
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |