On Tue, May 1, 2012 at 3:28 PM, Manfred Lotz <manfred.l...@arcor.de> wrote:
> Hi there, > What is a recommended Module for processing config resp. inifile > formats? > > One important feature I need is to use previously defined entries. > > Example: > > [General] > base_dir : /somedir > > [Files] > iso_image : ${base_dir}/x.iso > > lib : a.so > lib : b2.so > I am using Config::General - Generic Config Module. http://search.cpan.org/dist/Config-General/General.pm Say for example : The below is DB related information in my configuration goes <database> section : $ cat /etc/myconf.txt <database> mysql_host = localhost mysql_port = 3306 mysql_driver = mysql mysql_database = databasename mysql_username = mysqluser mysql_password = mysqlpassword mysql_socket = socket path </database> I am using the below code to parse configuration file. $cat myprog.pl my $conf_path = "/etc/myconf.txt"; my $conf = Config::General->new($conf_path); my %config = $conf->getall(); my %database = %{$config{database}}; my $mysql_host = $database{mysql_host}; my $mysql_port = $database{mysql_port}; my $mysql_driver = $database{mysql_driver}; my $mysql_database = $database{mysql_database}; my $mysql_username = $database{mysql_username}; my $mysql_password = $database{mysql_password}; my $mysql_socket = $database{mysql_socket}; Thanks Mohan L