Skip Menu |

This queue is for tickets about the Config-General CPAN distribution.

Report information
The Basics
Id: 41570
Status: resolved
Priority: 0/
Queue: Config-General

People
Owner: Nobody in particular
Requestors: fbicknel [...] nc.rr.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.40
Fixed in: (no value)



Subject: DefaultConfig fails to take array reference
I admit I may not be using -DefaultConfig properly, but when I pass it this hash everything operates as you would expect: 411 my $Defaults = { 412 Workflow => { 413 STEP => 'ONE', 414 THROUGH => 'TWO', 415 } 416 }; ... 'DefaultConfig' => HASH(0x40d4ed24) [snip] 'Workflow' => HASH(0x40d4dd78) 'STEP' => 'ONE' 'THROUGH' => 'TWO' 'ExtendedAccess' => 1 [snip] However, I would like now to do "something like" this: 411 my $Defaults = { 412 Workflow => { 413 STEP => [ 414 qw (ONE TWO THREE) 415 ] 416 } 417 }; I would expect this to give me something like the following. (This was taken from a config that looks like this - note there is no use of -DefaultConfig in this.) 12 <Workflow> 13 STEP = ONE 14 STEP = TWO 15 STEP = THREE 16 </Workflow> ... 'Workflow' => HASH(0x406ac318) 'STEP' => ARRAY(0x406ac798) 0 'ONE' 1 'TWO' 2 'THREE' 'ExtendedAccess' => 1 [snip] But instead, when I try to use -DefaultConfig with a hash as above (repeated here for reference), I get: 411 my $Defaults = { 412 Workflow => { 413 STEP => [ 414 qw (ONE TWO THREE) 415 ] 416 } 417 }; ... main::__ANON__[./DBBS:378]('Can\'t coerce array into hash at /dbbs212/perlmods/lib/Config...') called at /dbbs212/perlmods/l ib/Config/General/Interpolated.pm line 177 Config::General::Interpolated::_var_array_stacker('Config::General::Interpolated=HASH(0x406abff0)', 'ARRAY(0x406abd74)', 'ST EP') called at /dbbs212/perlmods/lib/Config/General/Interpolated.pm line 141 Config::General::Interpolated::_var_hash_stacker('Config::General::Interpolated=HASH(0x406abff0)', 'HASH(0x40d47838)') calle d at /dbbs212/perlmods/lib/Config/General/Interpolated.pm line 146 Config::General::Interpolated::_var_hash_stacker('Config::General::Interpolated=HASH(0x406abff0)', 'HASH(0x406ac170)') calle d at /dbbs212/perlmods/lib/Config/General/Interpolated.pm line 127 Config::General::Interpolated::_interpolate_hash('Config::General::Interpolated=HASH(0x406abff0)', 'HASH(0x406ac170)') calle d at /dbbs212/perlmods/lib/Config/General.pm line 136 Config::General::_process('Config::General::Interpolated=HASH(0x406abff0)') called at /dbbs212/perlmods/lib/Config/General.p m line 115 Config::General::new('Config::General', '-ConfigFile', '/dbbs212/config/spchp3/H10G6401.backup.config', '-ExtendedAccess', 1 , '-AutoTrue', 1, '-InterPolateVars', 1, ...) called at /dbbs212/perlmods/lib/Local/Config.pm line 422 I have tried passing it an array instead of an array reference and have also tried a string instead of a hash reference. Maybe I'm not using it right? $ perl -v This is perl, v5.8.6 built for PA-RISC2.0-LP64 $ uname -a HP-UX spchp1 B.11.11 U 9000/800 517750568 unlimited-user license
From: fbicknel [...] nc.rr.com
On Tue Dec 09 15:26:42 2008, fbicknel wrote: Show quoted text
> I admit I may not be using -DefaultConfig properly, but when I pass it > this hash everything operates as you would expect: > > 411 my $Defaults = { > 412 Workflow => { > 413 STEP => 'ONE', > 414 THROUGH => 'TWO', > 415 } > 416 }; > ... > 'DefaultConfig' => HASH(0x40d4ed24) > [snip] > 'Workflow' => HASH(0x40d4dd78) > 'STEP' => 'ONE' > 'THROUGH' => 'TWO' > 'ExtendedAccess' => 1 > [snip] > > However, I would like now to do "something like" this: > > 411 my $Defaults = { > 412 Workflow => { > 413 STEP => [ > 414 qw (ONE TWO THREE) > 415 ] > 416 } > 417 }; > > I would expect this to give me something like the following. (This > was > taken from a config that looks like this - note there is no use of > -DefaultConfig in this.) > > 12 <Workflow> > 13 STEP = ONE > 14 STEP = TWO > 15 STEP = THREE > 16 </Workflow> > ... > 'Workflow' => HASH(0x406ac318) > 'STEP' => ARRAY(0x406ac798) > 0 'ONE' > 1 'TWO' > 2 'THREE' > 'ExtendedAccess' => 1 > [snip] > > But instead, when I try to use -DefaultConfig with a hash as above > (repeated here for reference), I get: > > 411 my $Defaults = { > 412 Workflow => { > 413 STEP => [ > 414 qw (ONE TWO THREE) > 415 ] > 416 } > 417 }; > ... > main::__ANON__[./DBBS:378]('Can\'t coerce array into hash at > /dbbs212/perlmods/lib/Config...') called at /dbbs212/perlmods/l > ib/Config/General/Interpolated.pm line 177 > >
Config::General::Interpolated::_var_array_stacker('Config::General::Interpolated=HASH(0x406abff0)', Show quoted text
> 'ARRAY(0x406abd74)', 'ST > EP') called at /dbbs212/perlmods/lib/Config/General/Interpolated.pm > line 141 > >
Config::General::Interpolated::_var_hash_stacker('Config::General::Interpolated=HASH(0x406abff0)', Show quoted text
> 'HASH(0x40d47838)') calle > d at /dbbs212/perlmods/lib/Config/General/Interpolated.pm line 146 > >
Config::General::Interpolated::_var_hash_stacker('Config::General::Interpolated=HASH(0x406abff0)', Show quoted text
> 'HASH(0x406ac170)') calle > d at /dbbs212/perlmods/lib/Config/General/Interpolated.pm line 127 > >
Config::General::Interpolated::_interpolate_hash('Config::General::Interpolated=HASH(0x406abff0)', Show quoted text
> 'HASH(0x406ac170)') calle > d at /dbbs212/perlmods/lib/Config/General.pm line 136 > >
Config::General::_process('Config::General::Interpolated=HASH(0x406abff0)') Show quoted text
> called at /dbbs212/perlmods/lib/Config/General.p > m line 115 > Config::General::new('Config::General', '-ConfigFile', > '/dbbs212/config/spchp3/H10G6401.backup.config', '-ExtendedAccess', 1 > , '-AutoTrue', 1, '-InterPolateVars', 1, ...) called at > /dbbs212/perlmods/lib/Local/Config.pm line 422 > > I have tried passing it an array instead of an array reference and > have > also tried a string instead of a hash reference. > > Maybe I'm not using it right? > > $ perl -v > > This is perl, v5.8.6 built for PA-RISC2.0-LP64 > > $ uname -a > HP-UX spchp1 B.11.11 U 9000/800 517750568 unlimited-user license >
Here is a bit of additional information. I mentioned trying a string. A string with normal configuration information in it works just fine. But when I try this: 418 my $DefString = "<Workflow> 419 STEP = HERE 420 STEP = THERE 421 STEP = BEWARE 422 </Workflow>"; Then I get: main::__ANON__[./DBBS:378]('Can\'t coerce array into hash at /dbbs212/perlmods/lib/Config...') called at /dbbs212/perlmods/lib/Config/General/Interpolated.pm line 177 Config::General::Interpolated::_var_array_stacker('Config::General::Interpolated=HASH(0x40d4e33c)', 'ARRAY(0x40d4f3c4)', 'STEP') called at /dbbs212/perlmods/lib/Config/General/Interpolated.pm line 141 so basically the same error.
From: fbicknel [...] nc.rr.com
On Tue Dec 09 15:26:42 2008, fbicknel wrote: [snip] Another interesting bit: 12 # <<include config/spchp3/include.bc>> 13 <Workflow> 14 STEP = HERE 15 STEP = THERE 16 STEP = EVERYWHERE 17 STEP = BEWARE 18 </Workflow> This works, but if I put the identical code in the include file and uncomment the include line (commenting the inline <Workflow> set), it blows up as above. Seems that the only place this structure works is if it appears inline in the config file. All others blow up as above. Ok; I think I'm done. :)
From: fbicknel [...] nc.rr.com
On Tue Dec 09 15:26:42 2008, fbicknel wrote: [blah blah blah] Well! Would you look at that: if you remove -InterPolateVars => 1, it works as advertised. That's gotta be a clue... 135==> if ($self->{DefaultConfig} && $self->{InterPolateVars}) { 136: $self->{DefaultConfig} = $self->_interpolate_hash($self->{DefaultConfig}); # FIXME: _hashref() ? 137 } indeed 136 is where it blows up. Looks like FIXME needs fixing. :)
From: fbicknel [...] nc.rr.com
attached is a patch which seems to get around the problem, but I don't think interpolate is working right. So I assume this is not a complete solution. I was not able to quite figure out the __stack system, and time grows short, so.... Anyway, here's the patch. Hope it helps you track down the real issue.
Download patch
application/octet-stream 488b

Message body not shown because it is not plain text.

From: fbicknel [...] nc.rr.com
I'm afraid I have to retract that last post: something's still not right with the result. My apologies for that.
From: fbicknel [...] nc.rr.com
oops - bad data - it _does_ work. Again, with the exception of interpolating within the default structure; that doesn't work. But the patch does remove the nasty die() and the default config works as I just mentioned.
Hi, you're right, your fix is correct. The stack will be used later to replace variable with the content of some key with the name of a referred variable . However, variables can only be interpolated to some string. The code in question, which you commented out, tried to create a stack entry for the list elements. Which is nonsense. So, thanks for the finding, I applied the patch and will release it with 2.41.
Subject: RE: [rt.cpan.org #41570] DefaultConfig fails to take array reference
Date: Wed, 17 Dec 2008 13:46:43 -0500
To: <bug-Config-General [...] rt.cpan.org>
From: "Frank Bicknell (fbicknel)" <fbicknel [...] cisco.com>
Oh, cool: I've never done that before. :) Glad to have helped. Still using your module in development; thanks for the efforts. --- Frank Bicknell Cisco Systems, Inc. Show quoted text
-----Original Message----- From: T. Linden via RT [mailto:bug-Config-General@rt.cpan.org] Sent: Wednesday, December 17, 2008 10:45 AM To: fbicknel@nc.rr.com Subject: [rt.cpan.org #41570] DefaultConfig fails to take array reference <URL: https://rt.cpan.org/Ticket/Display.html?id=41570 > Hi, you're right, your fix is correct. The stack will be used later to replace variable with the content of some key with the name of a referred variable . However, variables can only be interpolated to some string. The code in question, which you commented out, tried to create a stack entry for the list elements. Which is nonsense. So, thanks for the finding, I applied the patch and will release it with 2.41.
done