use IO::Socket::INET; my $s = new IO::Socket::INET(PeerAddr => ..., PeerPort => ..., Proto => 'tcp'); unless ($s) { die "unable to connect..." } # we are connected, so just start sending commands print $s "first command\r\n"; my $resp = <$s>; # expect one line response print $s "second command\r\n"; ...