catfood has asked for the wisdom of the Perl Monks concerning the following question:

I am using the Config::Scopped module as I wanted inheritance of variables from different scopes. The documentation on CPAN (http://cpan.uwinnipeg.ca/htdocs/Config-Scoped/Scoped.html#declarations) states that "Blocks can be nested to any depth." I think I am missing something as I have the following data
# global scope dist = "/archive/"; %warnings parameter off; ### allow parameter redefinition aa1 { environment = T; aa2 { Xlogin = "jimmy"; } }
And it fails with the following error
Invalid decl item: Was expecting parameter or macro or comment or warn +ing but found "aa2 {" instead at /home/.../XMLConfigs/e.cfg line 11.
I use the following code to read it
#!/usr/local/bin/perl -w use strict; use Config::Scoped; use Data::Dumper; my $parser = Config::Scoped->new( file => 'e.cfg' ); my $config = $parser->parse; print Dumper($config);
Please let me know if I am doing something stupid or the module does not work as expected. Its version 1.31 (based on the top of the scoped.pm file) I think the latest on CPAN, I did an install Config::Scoped about an hour ago. If the module is in a bad way can someone suggest a module which allows variables to be inherited and redefined in different scopes. Basically this module is what I need if I could get it to work :) . This is perl, v5.6.1 built for i386-linux

Replies are listed 'Best First'.
Re: Config::Scoped module does not nest blocks as expected
by catfood (Novice) on Dec 13, 2004 at 03:01 UTC
    Should have read the documentation correctly. It does not say you can nest declaratations only blocks. Looks like the module will not be appropriate, oh so close :(
Re: Config::Scoped module does not nest blocks as expected
by metaperl (Curate) on Dec 13, 2004 at 18:29 UTC
      Config::ApacheFormat is definitely an improvement over what I was thinking of doing so thanks for that. I think I am getting a little carried away as I also want multiple inheritance in a config file. Not sure if this module will do this or is worthwhile extending it, may just make up the short comings in the code which reads it.