Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I don't think it is supported.
None of these modules fully support it.
#!/usr/bin/perl -- # Save as test.pl with test.pl.ini use strict; use warnings; use Data::Dumper; { # no way to override EOT heredoc multi use Config::IniFiles; my $cfg = Config::IniFiles->new( -file => __FILE__.'.ini' ) or die "error: IniFiles->new: @Config::IniFiles::errors"; my @values = $cfg->val( 'Trace', 'TRACE_MODULE' ); warn Dumper( \@values ),"\n . "; $cfg->WriteConfig( __FILE__.'.2.ini') or die "error: WriteConfig: +$!\n . "; use Shell::Command qw[ cat ]; cat __FILE__.'.ini'; cat __FILE__.'.2.ini'; } { # no multi support use Config::Tiny; my $Config = Config::Tiny->read( __FILE__ . '.ini' ); warn Dumper($Config),"\n . "; $Config->{Trace}{TRACE_MODULE} = [ qw[ mod1 mod2 ] ]; warn $Config->write_string,"\n . "; } { # multi via CSV ie TRACE_MODULE=mod1,mod2 use Config::Simple; my $cfg = Config::Simple->new( __FILE__.'.ini'); warn Dumper($cfg),"\n . "; } { # output is buggy (reversed... use Config::General; my $conf = new Config::General( -SplitPolicy => 'equalsign', -AllowMultiOptions => 'yes', # this is default -ConfigFile => __FILE__.'.ini', ); my %config = $conf->getall; warn Dumper( \%config ),"\n . "; warn $conf->save_string( \%config ),"\n . "; $conf->save_file( __FILE__.'.2.ini', \%config); use Shell::Command qw[ cat ]; cat __FILE__.'.2.ini'; } { # not for writing ini files, but for reading/validating use AppConfig; my $config = AppConfig->new({ PEDANTIC => 1, CASE => 1, }); $config->define( 'Trace_TRACE_MODULE=s@', ); $config->file( __FILE__.'.ini'); warn Dumper($config),"\n . "; warn $config->_dump,"\n . "; } { # no multi use Config::INI; # should do more than just declare package/pod use Config::INI::Reader; my $hash = Config::INI::Reader->read_file( __FILE__.'.ini'); warn Dumper($hash),"\n . "; } { # NOT allowmultiple for WriteINI use Config::IniHash; my $Config = ReadINI __FILE__.'.ini', allowmultiple => 1, ; warn Dumper( $Config ) ,"\n . "; WriteINI( __FILE__.'.2.ini', $Config ); use Shell::Command qw[ cat ]; cat __FILE__.'.ini'; cat __FILE__.'.2.ini'; } { # promising, but write_file is undocumented use Config::Mini; # write_file isn't a method either #~ my $config = Config::Mini->new ( __FILE__.'.ini', ); #~ warn Dumper( $config ) ,"\n . "; Config::Mini::parse_file ( __FILE__.'.ini', ); warn Dumper( \%Config::Mini::CONF ) ,"\n . "; Config::Mini::write_file ( __FILE__.'.2.ini', ); close Config::Mini::FP; # bug in Config::Mini 0.04 use Shell::Command qw(cat); cat( __FILE__.'.ini' ); cat( __FILE__.'.2.ini' ); }
I would submit a patch for Config::IniFiles, and subclass Config::IniFiles for personal use.

In reply to Re: Problem with Config::IniFiles multi-valued parameters and WriteConfig by Anonymous Monk
in thread 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 drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found