Perl Config::General setup and usage


Few libraries have been as useful to me over the years as Perl’s Config::General.

It gives us a simple way to create configurable scripts with minimal code, in a syntax-light configuration file format. The configuration file format is similar to apache’s, and the module can parse native apache configuration files.

How to start using it:

use Config::General;

my $conf = new Config::General("some_config.conf");
my %config = $conf->getall;

my $property = $config{some_property};

For this example, the configuration file could be as simple as:

some_property    "value"
<hostconfig>
    http_host             "thehost.com"
    http_port             8080
    http_timeout          30
</hostconfig>

For documentation and further details, check http://search.cpan.org/dist/Config-General/General.pm