Subject: | Config::General 2.33 Interpolation Problems |
Date: | Mon, 21 May 2007 16:11:49 -0400 |
To: | Bugs in Config-General via RT <bug-Config-General [...] rt.cpan.org> |
From: | Daniel Guilderson <dguilder [...] atg.com> |
I'm having trouble with Config::General 2.33. There seems to be a bug
in the interpolation code. It can be reproduced with the following
simple config file (also attached):
<outer b1>
test = foo
<inner>
ivar = $test
</inner>
</outer>
<outer b2>
test = bar
<inner>
ivar = $test
</inner>
</outer>
The above config is parsed into the following structure:
$VAR1 = {
'outer' => {
'b1' => {
'test' => 'foo',
'inner' => {
'ivar' => 'foo'
}
},
'b2' => {
'test' => 'bar',
'inner' => {
'ivar' => 'foo'
}
}
}
};
I used the following code to do this:
my %copts = (-ConfigFile => "example.cfg", -InterPolateEnv => 1,
-AutoTrue => 1);
my $cfg = new Config::General(%copts);
%conf = $cfg->getall();
print Dumper(\%conf);
As you can see, the ivar in the inner block of the second outer block
("b2") is incorrectly set to "foo". It should be "bar". For some
reason the $test variable is being interpolated in the scope of the "b1"
block rather than the "b2" block.
<outer b1>
test = foo
<inner>
ivar = $test
</inner>
</outer>
<outer b2>
test = bar
<inner>
ivar = $test
</inner>
</outer>