$_ ist the default variable for loops, you don't need a special inside variable.
If you got such a loop (and don't see any commands that could harm your computer), it's wise to
for (keys(%{$ini{$hostnames[$i]}})) { print "Slot: $_\n"; push @slots,$_; print "IfIndex: ${$ini{$hostnames[$i]}}{$_}\n"; push @ifindices,${$ini{$hostnames[$i]}}{$_}; }
This will show you what is happening.

Let's split the lines: $hostname[$i] contains your hostname. This is used as a key for the %ini - hash. So we could simplify it for better understanding as

for (keys(%{$Hostpart_from_INI})) {
$Hostpart_from_INI contains a reference to what Config::INI found for this hostname (the one for the current loop run). It is a Hash-Reference, so we could also write:
for (keys(%Host_Data_from_INI)) {
Okay, now we're here with a simple Hash. Each loop run gets another key from the Hash %Host_Data_from_INI. If you got Problems with $_, we could add it:
for $_ (keys(%Host_Data_from_INI)) {
You should try the following for better understanding:
perl -le 'for (1,2,3) { print $_; }'
You could also add the $_ behind the for or you could use any other variable.
Still with me? Okay, let's write your loop using the simplified form:
for (keys(%Host_Data_from_INI)) { push @slots,$_; push @ifindices,$Host_Data_from_INI{$_}; }
Remember: We changed nothing, the code is still the same. All we did was renaming things and solving references to show what Perl sees when executing the script.

In reply to Re^3: Ini files by Sewi
in thread Ini files by Ravendark

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.