Subject: | [PATCH] With CREATE = 1, HASH are always having a 1 key |
When trying to auto-create (CREATE = 1) a hash, the File module
systematically adds a key '1', per the set launched to create the variable:
# if the variable doesn't exist, we call set() to give
# AppConfig::State a chance to auto-create it
unless ($state->_exists($variable)
|| $state->set($variable, 1)) {
Even if it works for variables, lists, this doesn't work for hashes, as
it will systematically create the '1' key.
Proposed patch solves the proble; for me and is attached (against 1.63)
Subject: | AppConfig::File.patch |
--- /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm.orig 2007-08-09 17:44:26.000000000 +0200
+++ /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm 2007-08-09 17:44:32.000000000 +0200
@@ -20,7 +20,7 @@
require 5.005;
-use AppConfig;
+use AppConfig qw(:argcount);
use AppConfig::State;
use File::HomeDir;
@@ -227,6 +227,11 @@
my $nargs = $state->_argcount($variable);
+ # Fix a bug if the variable is a hash - 1 has been created as a key
+ if ($nargs eq AppConfig::ARGCOUNT_HASH) {
+ delete $state->{ VARIABLE }->{ $variable }};
+ }
+
# variables prefixed '-' are reset to their default values
if ($flag eq '-') {
$state->_default($variable);