in reply to Ini files
use Data::Dumper; print Dumper(\%ini)."\n";
And you have two typos:
push @slots, keys%{$ini{'$hostnames[$i}'}}; push @ifindices, values%{$ini{'$hostnames[$i}'}};
Please remember, that keys() and values() don't return the same order of items, so you won't get any associations between slots and ifindices. Try
for (keys(%{$ini{$hostnames[$i]}})) { push @slots,$_; push @ifindices,${$ini{$hostnames[$i]}}{$_}; }
Last note:
If you don't really need $i, you could advoid it:
In this loop, $_ is the same as $hostnames[$_] in your loop. For nested loops:for (@hostnames) { print $_; }
for my $Hostname (@hostnames) { print $Hostname; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Ini files
by Ravendark (Acolyte) on Sep 04, 2009 at 09:36 UTC | |
by Sewi (Friar) on Sep 04, 2009 at 11:06 UTC |