FilesSubmittedBranchesLabelsClientsUsersJobsHelp
Tree viewShow file textShow revision historyShow/hide recent activityInformation
//depot/projects/slashbox/slashbox.pl#1

//depot/projects/slashbox/slashbox.pl#1 – add change 70 (xtext) ·revision history

1#!/usr/bin/perl
2# slashbox.pl -- dump the latest headlines into /etc/motd.headlines so
3# people have something to read while the ssh applet loads.
4# zz9, may 2004
5#
6# cron: */30 * * * * /usr/local/bin/slashbox.pl > /etc/motd.headlines
7
8use strict;
9use LWP::Simple;
10use XML::RSS;
11
12my @feeds = (
13 [ 'Slashdot' => 'http://slashdot.org/index.rss' ],
14 [ 'Kuro5hin' => 'http://www.kuro5hin.org/backend.rdf' ],
15 [ 'BBC News' => 'http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss091.xml' ],
16);
17my $max = 5;
18
19print "--- ttul.org headlines, ", scalar(localtime), " ---\n\n";
20for my $f (@feeds) {
21 my ($name, $url) = @$f;
22 my $xml = get($url);
23 unless ($xml) {
24 print "[$name] (feed down. probably slashdotted. irony noted.)\n\n";
25 next;
26 }
27 my $rss = XML::RSS->new;
28 eval { $rss->parse($xml) };
29 if ($@) {
30 print "[$name] (bad XML)\n\n";
31 next;
32 }
33 print "[$name]\n";
34 my $n = 0;
35 for my $item (@{ $rss->{items} }) {
36 last if ++$n > $max;
37 my $t = $item->{title};
38 $t =~ s/\s+/ /g;
39 $t = substr($t, 0, 72) . "..." if length $t > 75;
40 print " * $t\n";
41 }
42 print "\n";
43}

P4Web/LINUX26X86/2005.1/82295 · Copyright © 1995-2005 Perforce Software · ttul.org