Question

Is it possible to tell the Config::IniFiles module to treat a multiline-value enclosed in " in a way which doesn't cause the whole parsing-process to fail? I have to deal with such an ini-file and unfortunately I can't change any of its content.

This is what it looks like

198 revive.msg.fm.email2= "
199 text text text
200 some more text
201 even more text
202
203 and some more"

Trying to parse the file with

 20 my $cfg_file = Config::IniFiles->new(
 21         -file => '/path/to/config_test.ini',
 22 ) || die Dumper \@Config::IniFiles::errors;

gives me

$VAR1 = [
    'Line 199 in file /home/zzzpetscript/config_test.ini is mal-formed:
    text text text',
    ...
];

I was looking at -allowcontinue 0|1, but that only works with trailing \, which I can't insert into the file, since I don't have any permissions to change those ini-files that I have to parse.

Was it helpful?

Solution

The CPAN documentation says :

Multi-line or multi-valued parameters may also be defined ala UNIX "here document" syntax:

Parameter=<<EOT
value/line 1
value/line 2
EOT

You may use any string you want in place of "EOT". Note that whatever follows the "<<" and what appears at the end of the text MUST match exactly, including any trailing whitespace.

Alternately, as a configuration option (default is off), continuation lines can be allowed:

[Section]
Parameter=this parameter \
  spreads across \
  a few lines

Have you tried either of those? (trying to fudge something else is probably hard work....)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top