Skip Menu |

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

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

People
Owner: tlinden [...] cpan.org
Requestors: dan [...] klein.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 2.32
  • 2.33
  • 2.34
  • 2.36
Fixed in: (no value)



Subject: Mixing blocks and single-value items
I'm not sure if I should refer to version 2.34 (which is $VERSION) or 2.36 (which is the tarfilenumber). Regardless... consider this config file: <show one> color green linetype dashed </show> <show two> color red </show> show three show four When I parse it using the following simple code: #!/usr/bin/perl use Data::Dumper; use Config::General qw(ParseConfig); %cfg = ParseConfig(-ConfigFile => '/tmp/foo'); print Data::Dumper::Dumper \%cfg; I see what I expect to see: $VAR1 = { 'show' => [ { 'one' => { 'color' => 'green', 'linetype' => 'dashed' }, 'two' => { 'color' => 'red', } }, 'three', 'four' ] }; However, if I swap the order of a show item with a show block, so that my config file reads like this instead: show three <show one> color green linetype dashed </show> <show two> color red </show> show four Then I get the following error: Can't use string ("three") as a HASH ref while "strict refs" in use at /usr/local/lib/perl5/ site_perl/5.8.5/Config/General.pm line 803. Note that setting -ApacheCompatible makes no difference. If I change the config thusly (so that there are 2 items before any block): show three show four <show one> color green linetype dashed </show> <show two> color red </show> Then I get a different (but related) error: Can't coerce array into hash at /usr/local/lib/perl5/site_perl/5.8.5/Config/General.pm line 803. And just to be complete, when I do this: <show one> color green linetype dashed </show> show three <show two> color red </show> show four I get yet another error, but at least Config::General recognizes a problem: Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.5/Config/General.pm line 803. Cannot add named block <show two> to hash! Block <show> occurs more than once. Turn on -MergeDuplicateBlocks or make sure <show> occurs only once in the config. at tx line 4 I understand why it is happening, but don't know how best to fix it (I could stumble my way through, but I suspect you'd do something neater, knowing the code better. I believe that the correct behavior is to always have Config::General produce data similar to that seen in the first example (rather than making all of them illegal with an error message). If you are curious, I use your module at http://www.klein.com/thermd/, and my workaround has been to create both a "show name" item and a "<show+ name>" block, which clunky but works... This is on FreeBSD 5.3, perl 5.8.5
This is not supported in the module. I added several checks against such cases, so instead of perl killing the script, Config::General now dies with a descriptive error message.
CC: tlinden [...] cpan.org
Subject: Re: [rt.cpan.org #30199] Mixing blocks and single-value items
Date: Sat, 24 Nov 2007 22:12:30 -0500
To: bug-Config-General [...] rt.cpan.org
From: Daniel V Klein <dvk [...] lonewolf.com>
Tom- Thank you anyway for looking, but waah! It would be a very useful feature! And I believe it would not break any backwards compatability... -Dan Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=30199 > > > This is not supported in the module. I added several checks against such > cases, so instead of perl killing the script, Config::General now dies > with a descriptive error message.
Show quoted text
> It would be a very useful feature!
Yes that is right, though. Show quoted text
> And I believe it would not break any backwards compatability...
I'm not sure. But it requires a lot of reqriting of the code, which in turn could lead to incompatibilities. You need to know that the module is in wide use, worldwide and it's almost stable. So I'll be very carefull with new features. I hope you understand it.
Subject: Re: [rt.cpan.org #30199] Mixing blocks and single-value items
Date: Mon, 26 Nov 2007 15:01:37 -0500
To: bug-Config-General [...] rt.cpan.org, tlinden [...] cpan.org
From: Daniel V Klein <dvk [...] lonewolf.com>
Of course I understand, I have modules in the CPAN myself :-) As to rewriting and compatability issues... I dunno, you know better. I yield. -Dan Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=30199 > >
> > It would be a very useful feature!
> > Yes that is right, though. >
> > And I believe it would not break any backwards compatability...
> > I'm not sure. But it requires a lot of reqriting of the code, which in > turn could lead to incompatibilities. > > You need to know that the module is in wide use, worldwide and it's > almost stable. So I'll be very carefull with new features. > > I hope you understand it.
case closed.