#!/usr/bin/perl
# RSS Robot v0.1 (2004.10.29)
# URL: http://private.ceek.jp/
use strict;
use IO::Socket;
use IO::Select;
my (@href, $selecter, $out_sock, $last_sock, %s, %r, %p, %c);
&init_href("http://private.ceek.jp/index.rdf");
&init_href("http://news.ceek.jp/rss/index.rdf");
$selecter = IO::Select->new;
foreach my $href (@href) {
	$SIG{'ALRM'} = sub {
		$out_sock++;
		next;
	};
	alarm(1);
	eval {
		my $sock;
		$sock = IO::Socket::INET->new("$s{$href}:80");
		if ($sock) {
			$selecter->add($sock);
			$p{$sock} = $href;
			print $sock "GET /$r{$href} HTTP/1.0\r\n";
			print $sock "Host: $s{$href}:80\r\n\r\n";
			$sock->flush();
		} else {
			$out_sock++;
		}
	}
}
$last_sock = $#href + 1 - $out_sock;
while ($last_sock > 0) {
	my ($readable_socks) = IO::Select->select($selecter, undef, undef, undef);
	foreach my $sock (@$readable_socks) {
		my ($len, $buf);
		$len = sysread($sock, $buf, 10240);
		if ($len > 0){
			$c{$p{$sock}} .= $buf;
		} else {
			$selecter->remove($sock);
			$sock->close();
			$last_sock--;
		}
	}
}
# RSS Parse
foreach my $href (@href) {
	$c{$href} =~ tr/\r\n/ /;
	while ($c{$href} =~ m|