sub os_port { foreach (@_) { $sock = new IO::Socket::INET(PeerAddr => $server, PeerPort => $_, Proto => 'tcp'); last if $sock; } $sock; } #### while (<$sock>) { $sock_string = $_; last; } #### $sock_string = <$sock>;