All pastes #356000 Raw Edit

Szymek

public text v1 · immutable
·published 2007-02-14 21:53 UTC
rendered paste body
#!C:/perl/bin/perl -w
use strict;
use POSIX;
use IO::Socket::INET;

my $sock = IO::Socket::INET->new('krakow.ircnet.pl:6667') or die "Can't connect: $!";
$sock->blocking(0);

print $sock "NICK $ARGV[0]\n";
print $sock "USER $ARGV[0] DD D D\n";

my $time = time+5;
my $last_recv = time;
my $line;

while (1) {
  $! = 0;
  if (! defined ($line = <$sock>)) {
    die "$!\n" unless $! == EAGAIN;
    die "Recv Timeout\n" if (time - $last_recv)>10;
  } else {
    $last_recv = time;
  }
  $_ = $line;
  
  if ($time<time) {
    print "DING\n";
    print $sock "QUIT\n";
    $time = time+5;
  }
  if ($_) {
    print $_;
  }
}