From trying to decipher your very poorly formatted code, it seems to me that the $oknode variable is reset properly to 0 for each @CONNECTCOMMANDS, and therefore also for each $TEMPHOST, which, to the best of my comprehension, is presumably what you are looking for.

Please do yourself a favor: learn how to indent code correctly: although the compiler does not care about indentation, humans do a lot, proper indentation is not optional, it is essential to the comprehension of what you're writing.

As an additional side note, whenever you start to name your variable $var1, $var2, $var3, this must ring an alarm that there is almost certainly something wrong in what you are doing. The 16 variables defined in your NODE sub should probably be an array of hashes, i.e. something like this:

my @nodes = ( { host => "somenode1.domain.local", username => "user", password => "password", parnode => 4 }, { host => "somenode2.domain.local", username => "user", password => "password", parnode => 4 } # ... );
This would avoid duplication of code that you have, for example, in the MSWin32 sub, and which could be something like this (untested):
my @CONNECTCOMMANDS; for my $host (@nodes) { push @CONNECTCOMMANDS, "$SSHCOMMAND -ssh $host->{username}\@$host + -pw $host->{password}"; }
although you most probably don't need two arrays, since the second one (@CONNECTCOMMANDS) does not contain anything new compared to the original one, so that you could either use directly the first array of hashes in your subsequent code, or decide to put your ssh commands directly in your initial reference data array:
my @connection_commands = ( 'plink.exe -ssh user1@somenode1.domain.local -pw password1', 'plink.exe -ssh user2@somenode2.domain.local -pw password2', # ... );
(replacing obviously user1, user2, password1 and password2 by their actual values).

Update: as I've just posted this answer, I see that you've just now deeply edited your original post, making some of my comments (and other monks' previous comments) look off-topic or unwarranted. When you change one of your posts, please keep the original post and add updates to show the difference between the OP and the updates, as I just did here.


In reply to Re: help with perl variables by Laurent_R
in thread help with perl variables by adamim

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.