in reply to format output from a exe within a perl script

I think your script will basically work. All you need to do is change $SITVAL to $VAL, i.e.
for(@PORTS){ ($KEY,$VAL)=split(/:/); $HOST=$VAL if $KEY =~ /Host/; $CONNTIME=$VAL if $KEY =~ /Connection time/; $CONNEDHOST=$VAL if $KEY =~ /Connected host/; ...
The only significant thing I would change is to use if/elsif/elsif/... to check for the various key/value pairs:
if ($KEY =~ /Host/) { $HOST = $VAL; } elsif ($KEY =~ /Connection time/) { $CONNTIME = $VAL; } elsif ($KEY =~ /Connected host/) { ... } ...
It's safer and more efficient.

Update: Note that you don't have to explicitly "delete the first three lines" of the output because none of the patterns you are matching against occur in the first three lines. However, if you want to be sure that the first three lines won't enter the for loop, you can eliminate them with:

splice(@PORTS, 0, 3);

Replies are listed 'Best First'.
Re^2: format output from a exe within a perl script
by parv (Parson) on Apr 02, 2008 at 03:40 UTC

    elsifs are misplaced here for OP wants to know about things in addition to the host.

    Later turns out it was my comment which was misplaced not elsif.

      I'm sorry if it wasn't clear, but I intended to keep the for loop and only replace the separate if statements with a single if/elsif/elsif/... statement, i.e.:
      for (@PORTS) { ($KEY, $VAL) = split(/:/); if ($KEY =~ /Host/) { $HOST = $VAL; } elsif ($KEY =~ /Connection time/) { $CONNTIME = $VAL; } elsif ... }
      Is that what you're referring to?
        Thanks for the clue bat. I missed to read your post carefully before my reply, namely I missed the creation of "KEY" in a loop.