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"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML::Simple chatterbox dumper
by mirod (Canon) on Aug 16, 2001 at 10:04 UTC |