I have installed the AppConfig In an attempt to try and write my own config files 
I have got this far:



#!/usr/bin/perl -w

use AppConfig qw/:argcount/;
#use strict;
use Data::Dumper;

$| = 1;

my $config = AppConfig->new();


$config->define(
                'VER'   => { ARGCOUNT => ARGCOUNT_LIST },
                'INC'   => { ARGCOUNT => ARGCOUNT_LIST },
               );

foreach my $file ('example.conf')
{
 $config->file($file) if -f $file;
}


my %varlist = $config->varlist('.*');
foreach my $varname (keys %varlist)
{
# print "Variable name $varname, value = ", Dumper($config->get($varname)), "\n";

$stuff =  Dumper($config->get($varname));

eval $stuff;

$varage .= "$VAR1 - ";

}

print "\$stuff: $stuff";

print "\n\n$varage";



######################################
The conf file looks like: 

#some stuff

VER = /usr/lib
VER = /home/httpd
INC = /etc/hosts
INC = /home/user

#######################################
This gives the output:

Name "main::VAR1" used only once: possible typo at config.pl line 32.
$stuff: $VAR1 = [
          '/etc/hosts',
          '/home/user'
        ];


ARRAY(0x81b3e58) - ARRAY(0x81b64d4) -




I am not sure how to go about utilziing this output properly within the structure of 
the program, I suppose I mean making the data structures available with in the scope 
of the program. I could pass it out to file and require it right back but I feel I may 
missing the point.

In short, I need to access the values in the hash that is generated by eval, and I 
need them to occupy space in the symbol table, hence the idea of passing the generated 
code out to a file and requiring it back in. Any ideas?


Reply via email to