in reply to Perl Sockets Problem

For a), changing the last few lines of the sending script to:
while (my $msg = <STDIN>) { print $sock "$msg\n"; } close $sock;
should do the trick. The receiver is already set up to keep listening until the socket gives it an EOF.

For b), I suppose a command-line switch to tell it whether to start in client (sender) or server (receiver) mode, then use the appropriate set of args to IO::Socket->new and corresponding while loop based on that.