This snippet gets the 10 most recently added nodes from perlmonks.org Insert into the GUI of your choice for a desktop ticker, etc.
use LWP::Simple; my $slurp = get("http://www.perlmonks.org/index.pl?node=Newest\%20Node +s"); $node{$1} = $2 while $slurp =~ /\?node_id=(\d+)\&[^>]*>([^<]*)/g; for ((reverse sort {$a <=> $b }keys %node)[0..9]) { print "<a href=\"http://www.perlmonks.org/index.pl?node_id=$_\">$n +ode{$_}</a>\n"; }

Replies are listed 'Best First'.
RE: PerlMonks Newest 10 Nodes Grabber
by btrott (Parson) on May 05, 2000 at 00:36 UTC
    This is nice. And now that vroom has very nicely made available the RDF file, we could use XML::RSS instead of having to hand-code the extraction code (although hand- coding is probably faster).

    So here's the same thing but using XML::RSS:

    #!/usr/local/bin/perl -w use strict; use constant URL => 'http://www.perlmonks.org/headlines.rdf'; use LWP::Simple; use XML::RSS; my $rss = new XML::RSS; $rss->parse( get URL ); for my $item (@{ $rss->{'items'} }) { print "<a href=", $item->{'link'}, ">", $item->{'title'}, "</a><br +>\n"; }
RE: PerlMonks Newest 10 Nodes Grabber
by kryten (Scribe) on May 04, 2000 at 22:04 UTC
    Nice Snippet, I really should get into LWP::Simple. One thing I noticed though.
    (reverse sort {$a <=> $b }keys %node)[0..9]
    Can be achived without the explicit reverse just by changing the order of $a and $b in the sort subroutine.
    (sort {$b <=> $a }keys %node)[0..9]
    Sorry to be pedantic, it was bugging me :)
      Yeah, but we can throw most of that snippet out the window now, as Vroom has told me about http://perlmonks.org/headlines.rdf

      So here is the rewritten snippet. (Note that it now retrieves 12 headlines instead of 10. Or how many ever Vroom decides to put into headlines.rdf)

      use LWP::Simple; $/ = undef; my $slurp = get("http://www.perlmonks.org/headlines.rdf"); push @node, [$1,$2] while $slurp =~ /<item>\s*<title\s*>([^<]*)<\/title>\s*<link\s*>([^< +]*)/gio; print map { "<a href=\"$_->[1]\">$_->[0]</a>\n" } @node;