#!/usr/bin/perl use strict; use warnings; use diagnostics; require LWP::UserAgent; sub check_xml; my $last = 0; for (;;) { $last = check_xml($last); sleep(60); } exit; sub check_xml() { my $last = shift; my $ua = LWP::UserAgent->new; # # OK, we need to grab this through a proxy since we're behind a firewall # $ua->proxy('http', 'http://nn.nn.nn.nn:8088/'); # # So go and grab the page # my $request = HTTP::Request->new('GET', 'http://www.perlmonks.org/index.pl?node=chatterbox%20xml%20ticker'); my $response = $ua->request($request); # # If it worked # my ($author, $time, $msg); if ($response->is_success) { { $/=''; $_ = $response->content; $_ = join ' ',m/^\\n)(.*?)\<\/message\>(\n)/mgis; } foreach (split /\n/, $_) { ($author, $time, $msg) = m/author=\"(.*?)\" time=\"(\d+?)\" (.*)/i; print "[$author]: $msg\n" if ($time > $last); } } return $time; }