[Catalyst] Defining ARRAY in Config::General config

Octavian Rasnita octavian.rasnita at ssifbroker.ro
Tue Sep 21 12:14:49 GMT 2010


Hi Andrew,

I tried:

C:\Documents and Settings\Teddy> perl -MConfig::General -e "print 
$Config::General::VERSION"
2.49

#The program:

use Config::General;
use Data::Dumper;

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

print Dumper \%conf;

#The configuration file:

<array2>
foo [ bar ]
</array2>

foo [ bar ]

#The result:

$VAR1 = {
          'foo' => '[ bar ]',
          'array2' => {
                        'foo' => '[ bar ]'
                      }
        };

So it seems it doesn't work as it should because it creates a scalar that 
contains "[ bar ]".

Am I missing something?

Thanks.

--Octavian

----- Original Message ----- 
From: "Andrew Rodland" <andrew at cleverdomain.org>
To: "The elegant MVC web framework" <catalyst at lists.scsys.co.uk>
Sent: Tuesday, September 21, 2010 11:27 AM
Subject: Re: [Catalyst] Defining ARRAY in Config::General config


> On Tuesday, September 21, 2010 02:52:52 am Octavian Rasnita wrote:
>> The problem appears when the array should have just a single item, 
>> because
>> in that case Config::General reports it as a scalar value.
>>
>> I don't know if there is a better way of defining a single-item array 
>> with
>> Config::General, but I found a workaround that may work. We can use
>> something like:
>
> With Config::General >= 2.47 and Config::Any >= 0.20, you can use the 
> syntax
> "foo [ bar ]" or "foo = [ bar ]" to set the key "foo" to an arrayref
> containing the single value "bar". The latest version of
> Catalyst::Plugin::ConfigLoader will ensure that you're up to date.
>
> Andrew
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: 
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/ 




More information about the Catalyst mailing list