First off.. There is a module to deal with telnet access via perl (Net::Telnet I think). I didnt realize how much extra there is to telnet as opposed to a simple socket, but Ill show you one way of using a socket, and then leave finding the others ways as an excercise (Seeing as you are spending so much time with this :) ).... Basically I am treating the socket below just like any other filehandle
#!/usr/bin/perl
use IO::Socket;
$socket = IO::Socket->new(
PeerAddr => 'somehost_or_ip',
PeerPort => 'some_port',
Proto => 'tcp',
Type => SOCK_STREAM,
);
die "Cant connect to remote host!\n" if (!$socket);
# Send a transmission
print $socket "$some_output\n";
# Receive a resonse back
chomp($line = <$socket>);
Granted the above assumes a plaintext transmission, and there are more appropriate ways of playing with sockets, but this will get it done for you. As a test use that method to communicate with a mailserver (POP or SMTP), and get a feel for the transmission flow.
If you need your transmission encrypted just go to search.cpan.org and search for Crypt, or Digest, and that should get you rolling, and for compression network transmission or otherwise, I like Compess::Zlib.
have fun and happy hacking :)
/* And the Creator, against his better judgement, wrote man.c */