Inspired by
OeufMayo's
XML::Parser Tutorial many months ago, i
wrote a similar version with
XML::Simple. Since
then, the computer the script resided on crashed, and i had
to rewrite it. So, i present it here in the hopes that
when my new computer crashes, i can get a copy here . . .
um, yeah.
Update: (Aug 20, 2001)
added 'forcearray' option to handle edge conditions (no
messages, one message)
use strict;
use XML::Simple;
use LWP::Simple;
use constant URL => q|http://perlmonks.org/index.pl?node=chatterbox+xm
+l+ticker|;
$| = 1;
my $cb_ticker = get(URL) or die "site down!";
my $xml = XMLin($cb_ticker,forcearray=>1) or die "xml error!";
foreach my $msg (@{$xml->{'message'}}) {
my $auth = $msg->{'author'} || '';
my $cont = $msg->{'content'} || '';
my $time = $msg->{'time'} || '';
$time = join(":", $time =~ /^\d{8}(\d\d)(\d\d)(\d\d)$/) if $time;
$cont =~ s/\n//g;
$cont =~ s/^\/me/$auth/;
print "$time - [$auth] $cont\n";
}