#!/usr/bin/perl -w use strict; use IO::Socket; my ( $server, $port, $my_nick, $channel, ) = ('irc.dal.net', 6667, 'foobot', '#hackerhost', ); my $sock = IO::Socket::INET->new(PeerAddr => $server, PeerPort => $port, Proto => "tcp", ); print $sock "USER $my_nick foo.wherever.com $server :Just another bot\n"; print $sock "NICK $my_nick\n"; $SIG{INT} = sub { print $sock "QUIT :Copped signint from owner\n"; close $sock; exit; }; SOCKLOOP: while (<$sock>) { if ( /^[A-Z]/ ) { if ( /^PING\s+:([\w.]+)/ ) { print $sock "PONG $1\n"; } next SOCKLOOP; #probably need to catch some other stuff but hey } else { my ($server,$action,$stuff) = /^:(\S+)\s+(\w+)\s+(.*)/; if ( $action =~ /\d+/ ) # Server response code { if ($action == 376 ) { print $sock "JOIN $channel\n"; } } } }