I hacked up some code to syndicate my old use.perl.org journal entries to caseywest.com. That was interesting. The highlights include: dateCreated says it takes ISO 8601 format, and it does, but only one variant of ISO 8601; modems are very slow, don't run this from your modem; overloaded operators are a funny thing when you aren't told they'll be there; and finally, broken HTML from the olden days isn't fun to go back and fix.
If you're interested, here's the code.
#!/usr/local/bin/perl
use warnings;
use strict;
use WWW::UsePerl::Journal;
use Net::MovableType;
use Time::Piece;
my $cutoff = Time::Piece->strptime(
'2002-12-11 15:34:00',
'%Y-%m-%d %H:%M:%S'
);
my $up = WWW::UsePerl::Journal->new( 'user' );
my %entries = $up->entryhash;
my $mt = Net::MovableType->new(
'http://example.com/xmlrpc',
'user',
'pass',
);
$mt->blogId( 1 );
foreach ( sort { $a <=> $b } keys %entries ) {
my $entry = $entries{$_};
next if $entry->date > $cutoff;
chomp( my $title = $entry->subject );
my $date = $entry->date->strftime( '%Y%m%dT%H:%M:%S' );
my $body = $up->entry( $entry->id );
printf "%s - %s\n", $date, $title;
post_mt( $mt, $title, "$body", $date );
}
sub post_mt {
my ($mt, $title, $descr, $date) = @_;
$mt->newPost({
title => $title,
description => $descr,
dateCreated => $date,
}, 1) || die $mt->errstr;
}
Posted from caseywest.com, comment here.