Slash Boxes
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)

  (email not shown publicly)
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 journal entries to 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.

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(
$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) = @_;
title => $title,
description => $descr,
dateCreated => $date,
}, 1) || die $mt->errstr;

Posted from, 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.
More | Login
Loading... please wait.