use strict; use warnings; use IO::Socket::INET; my $sock = IO::Socket::INET->new( PeerAddr => '123.45.67.89', # IP address PeerPort => '2000', # port Timeout => '60' # timeout in seconds ); # rest of your code using $sock.