in reply to problem in printing the result in the out put file

Hello hegaa,

Also another quick tip Don't Open Files in the old way. Open them in the new way (open)

Did not test the code.

open(my $out, '>>', 'port.txt') or die "Can't open < port.txt: $!"; print $out "\n$ip:$port\n"; close($out) or die "Can't close < port.txt: $!";;
Seeking for Perl wisdom...on the process of learning...not there...yet!