#!/usr/bin/perl -w use strict; use XML::Rules; use LWP::Simple; # used to fetch the chatterbox ticker my $cb_ticker = get("http://perlmonks.org/index.pl?node=chatterbox+xml+ticker"); my $parser = XML::Rules->new( stripspaces => 7, rules => { message => sub { my ($tag, $atts) = @_; $atts->{'_content'} =~ s/\n//g; my ($y,$m,$d,$h,$n,$s) = $atts->{'time'} =~ m/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/; # Handles the /me $atts->{'_content'} = $atts->{'_content'} =~ s/^\/me// ? "$atts->{'author'} $atts->{'_content'}" : "<$atts->{'author'}>: $atts->{'_content'}"; $atts->{'_content'} = "$h:$n " . $atts->{'_content'}; print "$atts->{'_content'}\n"; return; }, 'INFO,CHATTER' => 'pass', } ); $parser->parse($cb_ticker);