Subject: | 2.52 CRLF-ini with multi-value params fails under Linux |
This ini file
1:# This ini-file has DOS-style line endings (CRLF)
2:[app_params]
3:pathes = <<EOTP
4:path1
5:path2
6:EOTP
7:
read by the script below
works on windows:
Show quoted text
>initest.pl
Created
pathes:
path1
path2
fails on Linux:
# ./initest.pl
Can't use an undefined value as a symbol reference at
/usr/lib/perl5/site_perl/5.8.8/Config/IniFiles.pm line 682, <GEN0> line 56.
After changing the ini to UNIX line feeds it is working on both systems.
The idea however, is that the same configurations should be
interchangeable between platforms. And in our case should be editable by
layouters with little understanding of the backgrounds.
Same test script on both systems:
#!/usr/bin/perl
use strict;
use warnings;
use Config::IniFiles;
my $defaultcfg = new Config::IniFiles -file => './initest.ini'
or die "Error reading from './initest.ini': $!";
print "Created\n";
if ($defaultcfg->exists('app_params', 'pathes')) {
my @pathes = $defaultcfg->val('app_params', 'pathes');
print "pathes:\n", join("\n", @pathes), "\n";
}
exit 0;
Trying to figure it out myself, I found that in sub ReadConfig on Linux
and inside the loop on "here" values the \x0a part is being left over by
the generic line separator:
$self->{line_ends}='\x0d'
$eotmark='EOTP'
$_='
path1'=\x0a\x70\x61\x74\x68\x31
$_='
path2'=\x0a\x70\x61\x74\x68\x32
$_='
EOTP'=\x0a\x45\x4f\x54\x50
$_=''=
$foundeot='0'
Unfortunately I have no idea how this can be solved in an easy way. (And
without possibly corrupting unicode input.)
Thank you,
Steffen Heinrich