in reply to Re^12: Config files
in thread Config files
I told you the code looks into the current section if you do not specify the section name. I don't think it's wise to search for the values in other sections, but if you want the code can easily be changed to do that.
With this if the user doesn't specify the section name then the option is first looked up in the current section and then in all already read sections. If the option was specified in several versions then you end up with the value from a "random" one. Hashes do not preserve order so the code cannot tell in what order were the section in the INI file.$value =~ s{%(?:\[([^\]%]+)\])?([^%]*)%}{ if ($2 eq '') { '%' } elsif ($1 eq '') { if (exists $INIhashref->{$sectionname}{$2}) { $INIhashref->{$sectionname}{$2} } else { my $found; foreach my $section (values %$INIhashref) { if (exists $section->{$2}) { $found = $section->{$2}; last; } } $found } } else { $INIhashref->{$1}{$2} } }ge;
If you did want to take the into consideration you'd have to instruct Config::IniHash to store the order in @{$config->{'__SECTIONS__'}} using the sectionorder parameter. See the docs. You'd then loop through the @$INIhashref{@{$INIhashref->{'__SECTIONS__'}}} instead of <code>values %$INIhashref. (The scary looking code in the previous line is a hash slice, using the array referenced by $config->{'__SECTIONS__'} as the list of keys.
Jenda
|
We'd like to help you learn to help yourself Look around you, all you see are sympathetic eyes Stroll around the grounds until you feel at home -- P. Simon in Mrs. Robinson |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^14: Config files
by sparkel (Acolyte) on Dec 15, 2004 at 03:24 UTC | |
by Jenda (Abbot) on Dec 15, 2004 at 15:01 UTC | |
by sparkel (Acolyte) on Dec 20, 2004 at 16:59 UTC | |
by sparkel (Acolyte) on Feb 02, 2005 at 00:14 UTC |