Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: rafporti [...] cisco.com
Cc:
AdminCc:

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



Subject: get is different from save
Date: Thu, 20 Nov 2014 22:20:19 +0000
To: "bug-Config-General [...] rt.cpan.org" <bug-Config-General [...] rt.cpan.org>
From: "Fabian Portilla -X (rafporti)" <rafporti [...] cisco.com>
If I create a configuration using the perl module and then retrieve the data, it is different from what I saved. One instance is with keys that have spaces in them. There are others, but I don't have a ready example. In this first case, create a hash with a key that has a space and save the file. When you get the file it will return the first word as the key and the following words in the data. The behavior I would expect is to quote the key in the config file. Thanks.
What's the documented handling of keys with spaces, I wonder? Does it (or the Apache docs) ever say?
Subject: RE: [rt.cpan.org #100483] get is different from save
Date: Thu, 20 Nov 2014 22:39:39 +0000
To: "bug-Config-General [...] rt.cpan.org" <bug-Config-General [...] rt.cpan.org>
From: "Fabian Portilla -X (rafporti)" <rafporti [...] cisco.com>
As far as I know, Apache keys are reserved keywords. You would not create your own. However, I thought this module was for general configuration handling. And as long as you are doing configuration based on strings, arrays and hashes, I would think that you should be able to store it in the configuration. Right now, it allows you to save it without error and then reads it back in incorrectly. If this is not legal, I suggest that it be documented and produce an error instead of silently doing the wrong thing.
You need to set -SplitPolicy to 'equalsign' and separate options from values using equal signs. Or, you could set -SplitDelimiter and -StoreDelimiter to something of your own choosing. Sample script: #!/usr/bin/perl use Config::General; use Data::Dumper; my $str = join '', <DATA>; my $cfg = Config::General->new(-String => $str, -SplitPolicy => 'equalsign'); my %hash = $cfg->getall; print "# parsed original:\n"; print Dumper(\%hash); print "\n# saved:\n" . $cfg->save_string . "\n"; my $cfg2 = Config::General->new(-String => $cfg->save_string, -SplitPolicy => 'equalsign'); my %hash2 = $cfg2->getall; print "# parsed from save:\n"; print Dumper(\%hash2); __DATA__ val one = 1 val two = 2 Output: # parsed original: $VAR1 = { 'val two' => '2', 'val one' => '1' }; # saved: val two = 2 val one = 1 # parsed from save: $VAR1 = { 'val two' => '2', 'val one' => '1' }; This behavior has nothing to do with apache, as the whole module doesn't have anything to do with apache. It is only able to parse apache configs among other things. best, Tom