in reply to Re^7: Config files
in thread Config files
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Config files
by Jenda (Abbot) on Dec 11, 2004 at 17:33 UTC | |
by sparkel (Acolyte) on Dec 11, 2004 at 23:52 UTC | |
by Jenda (Abbot) on Dec 12, 2004 at 00:24 UTC | |
by sparkel (Acolyte) on Dec 12, 2004 at 00:39 UTC | |
by Jenda (Abbot) on Dec 12, 2004 at 01:55 UTC | |
|