Name: Anonymous 2011-01-19 23:04
Not sure if this board is helpful with this kind of stuff, but I'm trying to teach myself perl by writing simple scripts. This is an rss reader that prints with text I want to the command prompt. It will sometimes print items that don't contain the text, it also displays items with the text at least twice.
Anything obvious?
Anything obvious?
#!/usr/bin/perl
$feed_link="http://boards.4chan.org/n/index.rss";
$feed_file="/scripts/rss/feed.txt";
@linkarray = (" ");
while(1) {
system("wget -q $feed_link -O /scripts/rss/feed.txt");
open(RSSFILE, "<", $feed_file);
while(<RSSFILE>)
{
if(/<item>/../<\/item>/)
{
if(/<title>/../<\/title>/)
{
$whitespace = index $_, "<";
$title_string = substr $_, $whitespace;
$title_string =~ s/<title>//g;
$title_string =~ s/<\/title>//g;
chomp($title_string);
}
elsif(/<link>/../<\/link>/)
{
$whitespace = index $_, "<";
$link_string = substr $_, $whitespace;
$link_string =~ s/<link>//g;
$link_string =~ s/<\/link>//g;
chomp($link_string);
}
elsif(/<description>/../<\/description>/)
{
$whitespace = index $_, "<";
$description_string = substr $_, $whitespace;
$description_string =~ s/<description>//g;
$description_string =~ s/<\/description>//g;
chomp($description_string);
}
}
if($link_string ~~ @linkarray) { }
else
{
if(($title_string =~ m/(deen|studio|a)/i) or ($description_string =~ m/(deen|studio|a)/i))
{
print "\n********************\n$title_string\n$link_string\n********************\n";
push(@linkarray, $link_string);
}
}
}
sleep(60);
}