Hi Jenda,

Thanks for the response. Does that mean I need to hardcode the names of arrays that will be written in the config file to put them in the "qw()" ?

So, if my config file contains:

[one] size = 1,2,3,4 root = C:\test [two] colors = red,blue,green code = %root%\code1

Then, having:

use Config::IniHash qw(ReadINI); use Data::Dumper; $config = ReadINI('testiINI.ini', systemvars => 0, forValue => sub { my ($name, $value, $sectionname, $INIhashref) = @_; next if /^(#.*)?$/; $value =~ s{%(?:\[([^\]%]+)\])?([^%]*)%}{ print "for value: $value this is 1: $1 this is 2: $2 \n\n" +; if ($2 eq '') { '%' } elsif ($1 eq '') { $INIhashref->{$sectionname}{$2} } else { $INIhashref->{$1}{$2} } }ge; return $value; } ); foreach my $Section (values %$config) { foreach my $value ( qw( colors size ) ) { $Section->{$value} = [split /\s*,\s*/, $Section->{$value}]; } }

I am not sure if that is what you meant...but I am not too sure what you said should go into the qw(). How does the code determine what is the scalar variable and what is an array? Thank you.


In reply to Re^8: Config files by sparkel
in thread Config files by sparkel

Title:
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, details, 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, summary, 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.