Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'm trying to read some third party INI files using Config::IniFiles. I'm using the latest Config::IniFiles v2.52 with perl v5.8.8. I've never used Config::IniFiles before.

Given a simple example third party INI file, fred.ini, as follows:

[Trace] TRACE_MODULE=mod1 TRACE_MODULE=mod2
running this program:
use strict; use warnings; use Data::Dumper; use Config::IniFiles; my $cfg = Config::IniFiles->new( -file => 'fred.ini' ) or die "error: IniFiles->new: @Config::IniFiles::errors"; my @values = $cfg->val( 'Trace', 'TRACE_MODULE' ); print Dumper( \@values ); $cfg->WriteConfig( 'fred2.ini' ) or die "error: WriteConfig: $!\n";
emits:
$VAR1 = [ 'mod1', 'mod2' ];
and produces a new ini file, fred2.ini, as follows:
[Trace] TRACE_MODULE= <<EOT mod1 mod2 EOT
That is, Config::IniFiles seems to read the INI file ok, but writes it out in a different "<<EOT here document" format.

I need the new INI file to be written in its original format. Otherwise, the third party application is unable to read the updated INI files that I produce.

From reading the Config::IniFiles docs, it's unclear to me whether the third party multi-valued parameter INI file format, namely:

TRACE_MODULE=mod1 TRACE_MODULE=mod2
is officially supported. Though Config::IniFiles seems to read this format happily enough, it's not mentioned in its docs and I can see no way to make WriteConfig() emit a multi-valued parameter in this format.

There are many ways I could solve this problem. I could raise a Config::IniFiles ticket/patch enhancing this module to handle my third party multi-value parameter format. Or look for a different INI file module, write my own, ... Suggestions on how to solve my problem are welcome.


In reply to Problem with Config::IniFiles multi-valued parameters and WriteConfig by eyepopslikeamosquito

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-18 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found