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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.