Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #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 with 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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (10)
    As of 2021-05-06 14:55 GMT
    Find Nodes?
      Voting Booth?
      Perl 7 will be out ...

      Results (77 votes). Check out past polls.