#!/usr/bin/perl use warnings; use strict; use IO::Socket::INET; $/ = "\r\n"; my $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => 3009, Proto => 'tcp', ) or die "Couldn't create socket: $!"; print "Registering JOIN.\n"; print $socket "REG JOIN\n"; while (<$socket>) { chomp; print "Received $_\n"; next unless (/^JOIN/); s/^[^\t]*\t// || next; # Remove the entire first field. s/\t/ Hello, \$NICK\t/ || s/$/ Hello, \$NICK./; print "Saying ", $_, "\n"; print $socket $_, "\n"; }