AppConfig failure with ARGCOUNT_LIST

AppConfig failure with ARGCOUNT_LIST

am 22.05.2007 16:33:18 von margin

All,

I'm back to Perl after some time away. I'm attempting to use AppConfig
to read in a conf file that contains a list of attributes. I'm have
an action setup and each value is being read. For some reason only the
last entry, "version", is being set.

message.conf
[MESSAGE]
ATTRIBUTE=transactionId
ATTRIBUTE=sessionId
ATTRIBUTE=version


my $config = AppConfig->new();
$config->define(
MESSAGE_ATTRIBUTE =>
{ARGCOUNT => ARGCOUNT_LIST,
ACTION => \&validate,
}
);

When I dump the config contents I see this:

'ARGCOUNT' => HASH(0x19d65d0)
'message_attribute' => 'ARGCOUNT_LIST'
...
'PEDANTIC' => 0
'VALIDATE' => HASH(0x19d6600)
empty hash
'VARIABLE' => HASH(0x19c5f14)
'message_attribute' => 'version'

Any thoughts?

Thanks,
Bill S.

Re: AppConfig failure with ARGCOUNT_LIST

am 24.05.2007 11:50:06 von Christian Winter

margin wrote:
> I'm back to Perl after some time away. I'm attempting to use AppConfig
> to read in a conf file that contains a list of attributes. I'm have
> an action setup and each value is being read. For some reason only the
> last entry, "version", is being set.
>
> message.conf
> [MESSAGE]
> ATTRIBUTE=transactionId
> ATTRIBUTE=sessionId
> ATTRIBUTE=version
>
>
> my $config = AppConfig->new();
> $config->define(
> MESSAGE_ATTRIBUTE =>
> {ARGCOUNT => ARGCOUNT_LIST,
> ACTION => \&validate,
> }
> );
>
> When I dump the config contents I see this:
>
> 'ARGCOUNT' => HASH(0x19d65d0)
> 'message_attribute' => 'ARGCOUNT_LIST'
> ...
> 'PEDANTIC' => 0
> 'VALIDATE' => HASH(0x19d6600)
> empty hash
> 'VARIABLE' => HASH(0x19c5f14)
> 'message_attribute' => 'version'
>
> Any thoughts?

You forgot to import the ARGCOUNT constants (that's why
ARGCOUNT_LIST gets parsed as a string instead of the integer
value of the constant).

use AppConfig qw(:argcount);
should do the trick.

-Chris