Ravendark has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys,
I have this ini file:
[performance] pop1 = 192.168.1.1 pop2 = 192.168.1.2 [pop1] 2 = 123 2 = 345 4 = 125 [pop2] 6 = 503 10 = 444
and I do this:
sub mklist() { my $config = "/home/portal/test/performance.conf"; my %ini; tie %ini, 'Config::IniFiles', ( -file => $config); push @hostnames, keys%{$ini{'performance'}}; push @ips, values%{$ini{'performance'}}; #print "Hosts: @hostnames\n\n"; #print "IPs: @ips\n\n"; for (my $i = 0; $i < @hostnames; $i++) { push @slots, keys%{$ini{'$hostnames[$i]'}}; ## Here something +is wrong... push @ifindices, values%{$ini{'$hostnames[$i]'}}; } print "Slots: @slots\n\n"; ## this prints nothing print "Indices: @ifindices\n\n" ## this prints nothing as well... }
what is wrong in my code and the arrays @slots & @ ifindices are empty?? thanks!
P.S. If I do this:
push @slots, keys%{$ini{'pop1'}};
I get: 2 4 instead of 2 2 4
Why?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ini files
by Sewi (Friar) on Sep 04, 2009 at 08:52 UTC | |
by Ravendark (Acolyte) on Sep 04, 2009 at 09:36 UTC | |
by Sewi (Friar) on Sep 04, 2009 at 11:06 UTC | |
|
Re: Ini files
by ig (Vicar) on Sep 04, 2009 at 10:04 UTC | |
|
Re: Ini files
by Anonymous Monk on Sep 04, 2009 at 08:57 UTC | |
by Ravendark (Acolyte) on Sep 04, 2009 at 09:22 UTC | |
by Anonymous Monk on Sep 04, 2009 at 09:55 UTC | |
|
Re: Ini files
by andreas1234567 (Vicar) on Sep 04, 2009 at 10:07 UTC | |
by Anonymous Monk on Sep 04, 2009 at 10:35 UTC | |
by grep101 (Initiate) on Sep 05, 2009 at 02:59 UTC |