A website by Jeffrey Veen   more →

Publishing Links With Perl

12 Dec 2003

In the continuing saga of publishing my del.icio.us links, I’ve taken a turn towards Perl. For those of you following along, I started by pointing Feedroll at the auto-generated RSS, then used a Javascript include to show them here. That was cool, but I decided Jason was probably on to something by publishing to them in-line. So I took a stab at XSLT, transforming the output of the del.icio.us API into XHTML, then inserting that into MT. That worked ok, too, and you can see the Perl script I used here, along with the XSLT stylesheet here. But it felt convoluted. Too many dependencies. This talks to that which parses this into that, etc.

While I like XSLT a lot, I found that by using the Perl XPath module, the script almost wrote itself. Anyone familiar with URLs will pick up XPath in an instant. You just enter the path of /the/tag/you/want/, ask for either the text() inside the tag or one of its @attribute, then stuff it in a variable. Easy! So here is the script I’m using now. It pulls the XML over (now with verification that links were posted), turns it into XHTML, then sticks it into MovableType and rebuilds the site. You could easily just chop off the MT stuff at the end and just write it to a file, as well. Bear in mind that this represents about twice as much Perl as I’ve ever written before. But it seems to work. Comments please. ​