# Slashlib a library for using slashdot from perl programs
# Code contributed by most of the regulars on sid=slashcode
# Things to do....
# Make this into a proper perl module
# Provide POD documentation
# Think up more aubroutines to add...userinfo, search,
$slashdot = 'http://slashdot.org/';
$sidref = 'comments.pl?threshold=-1&mode=nested&commentsort=1&sid=';
$user_agent = "Slashlib 0.2";
# sd_articles: return a list of recent Slashdot article sids
sub sd_articles {
my ($source, @articles);
$source = shift || "comments.pl";
my $out=geturl($slashdot.$source,$slashdot);
while($out =~ m/article\.pl\?sid=([^">]+)/g){
push @articles, $1;
}
return @articles;
}
# Return SID at top of slashdot.org
sub sd_current_sid{
my $out=get_url("$slashdot");
$out =~ /sid=(.*?)">Read/i;
return $1;
}
# Return moderation totals on post
sub sd_mods {
my $sid = shift;
my $cid = shift;
my $out=geturl($slashdot.$sidref.escape($sid)."\&cid=$cid",$slashdot);
if ($out =~ m#Totals:([^<]+)#) {
return $1;
}
}
# Return information about a sid
sub sd_sidinfo {
my ($sid) = shift;
my ($i, %counts);
my $out=geturl($slashdot.$sidref.$sid ,$slashdot);
$out=~ m/Threshold: