working in "production":
#!/usr/bin/perl
use lib qw( /mnt/web4/10/47/51683347/htdocs/lib/site_perl/5.8.5 );
use warnings;
use strict;
use DBI;
use WWW::Mechanize;
use XML::Simple;
my ($sth, $dbh, $xml);
my $messages = [];
my $mech = WWW::Mechanize->new();
while (1)
{
my $resp = $mech->get( 'http://www.perlmonks.org/index.pl?node_id=
+207304' );
if ( $resp->is_success )
{
my $xml = $resp->content;
my $jatter = XMLin( $xml, ForceArray => ['message'] );
if ( $jatter->{info}->{count} > 0 )
{
print STDERR "adding ", scalar @{$jatter->{message}}, "\n"
+;
unless ( $dbh )
{
$dbh = DBI->connect("DBI:mysql:database=DB354211;host=
+rdbms.strato.de", 'U354211', 'pw354211');
$sth = $dbh->prepare('INSERT INTO pmf_jatterboxx (user
+_id, author, epoch, message_id, message) VALUES (?, ?, ?, ?, ?)');
}
for ( @{$jatter->{message}} )
{
$sth->execute( $_->{user_id}, $_->{author}, $_->{epoch
+}, $_->{message_id}, $_->{text} );
}
}
else
{
print STDERR "snooze\n";
}
}
sleep(5);
}
note: It is not obvious, but the chatterbox feed somehow notices the caller and returns only the chat-lines that are new; even without passing a date flage or something. I am curious how that works.