Subject: | Parameter values with a trailing '\' charater not saved corretly |
I was just writing a script that needed to store "C:\" in a config file. It looks like Config::Simple is failing to escape the \ on saving. Then when loading, it's interpreted a a line continuation, and retrieving the wrong value (for ini) or failing to load (simple, http).
The following is a test script:
use strict;
use warnings;
use Config::Simple;
my $value = 'C:\\'; # Ends in a \
my $file = 'test.';
foreach my $syntax ('ini', 'http', 'simple') {
print $syntax.": ";
unlink($file.$syntax);
my $cfg_out = Config::Simple->new(syntax => $syntax);
$cfg_out->param('test.value', $value);
$cfg_out->write($file.$syntax);
print "Wrote=[$value] ";
$cfg_out = undef;
if (my $cfg_in = Config::Simple->new(filename => $file.$syntax, syntax => $syntax)) {
my $input = $cfg_in->param('test.value');
print "Read=[$input] ";
$cfg_in = undef;
print $input eq $value ? "Ok\n" : "Not Ok\n";
} else {
print "Failed to load\n";
}
}