Skip Menu |

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

Report information
The Basics
Id: 99394
Status: rejected
Priority: 0/
Queue: Config-General

People
Owner: Nobody in particular
Requestors: daviddlowe.flimm [...] gmail.com
Cc:
AdminCc:

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



Subject: Quoting doesn't work for keys like it does for values
Take this configuration: foo = bar "foo2 2" = bar foo3 = "bar 3" With -SplitPolicy in its default value, this gives this result: { 'foo' => 'bar', '"foo2' => '2" = bar', 'foo3' => 'bar 3', } With -SplitPolicy set to "equalsign", this gives this result: { 'foo' => 'bar', '"foo2 2"' => 'bar', 'foo3' => 'bar 3', } You can see that double quotes are treated one way for values, and another way for keys. I would like it to be treated identically, so that the results are (with either setting for -SplitPolicy): { 'foo' => 'bar', 'foo2 2' => 'bar', 'foo3' => 'bar 3', }
Hi, sorry for the late reply. I'm not going to change this anytime soon, if ever. Quote parsing for values is already a messy business, doing the same for keys would just double the mess. If quoted keys would be supported than I would need to add different behavior for single and double quotes and stuff like that. Eg: "some key" one = 123 what would be the key? Should this be an error? or: 'my = var' = 89 where to split here? Intuitively I'd say, the key should be "my = var" because there are single quotes which people consider that it marks the stuff in between to be kept "as is". So I could not just apply the Split Policy, split keys and values and then removing eventually existing quotes on keys. IF there were quote support for keys, it should work like quotes usually tend to work. That means, I had to parse for quoted keys first and then applying the Split Policy, which makes things complicated internally. So, I'm not going to implement this anytime soon, sorry. However, you could achieve something like this using a plugin: my $conf = Config::General->new( -ConfigFile => shift(), -SplitPolicy => 'equalsign', -Plug => { 'post_read' => sub { my $lines = shift; my @new; foreach my $line (@{$lines}) { $line =~ s/^\"([^\"]*)\"/$1/; # remove quotes around keys, if any push @new, $line } return (1, \@new); } } ); config: use = blah "ano ther" = foo output: $VAR1 = { 'use' => 'blah', 'ano ther' => 'foo' }; best regards, Tom