Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cwest (1514)

cwest
  (email not shown publicly)
http://caseywest.com/
AOL IM: caseyrwest (Add Buddy, Send Message)

Perl geek.

Journal of cwest (1514)

Thursday October 16, 2003
04:47 AM

Backdicating My Journal

[ #15240 ]

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.

New comment creation has been disabled on this discussion.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login
Loading... please wait.