#!/usr/bin/perl use feature qw/say/; use warnings; use strict; use IO::Socket; # initialize host and port my $port = shift || 7890; my $server = "localhost"; # Host IP running the server my $socket = IO::Socket::INET->new( PeerAddr => $server, PeerPort => $port, Proto => "tcp", Type => SOCK_STREAM ) or die "Can't connect to server: $@\n"; while(<$socket>) { say; } close $socket or die "Can't close socket: $!";