Code TODOs to RSS

I live by my to-do list. Without it, I’d be a drippy mess of procrastination, and you wouldn’t be reading this book right now. It’s good to be organized, and especially so with code. Working on the scripts and chapters in this book, I’ve started to leave messages to myself within them. I mark these out as a new line starting with TODO:.

I then have this script run over all of my working directories, parsing each file and looking for those lines. The result is a nice to-do list in my reader application and a morning’s work all set out.

Walking Through the Code

We’ll do the usual start, with strict;, warnings;, CGI and XML::RSS. Let’s use the File::Find module to do the directory-traversing:

use strict;
use warnings;
use XML::RSS;
use CGI qw(:standard);
use File::Find;

Up near the top, we set the root directory, below which everything will be parsed. You need to change this to match your own setup, but remember that the script checks every file. Setting it to something too high up your filesystem tree might slow the script down magnificently.

my $start_directory = "/Users/ben/Code/";

Now, set up the RSS feed, as per usual. Here, we’re using a cunning trick, technically against the RSS 2.0 specification, of making the link element a file:// URL. This usually works very well, bringing up your OS’s file manager, or the application associated with that particular file, but remember that technically, it’s not supposed to work at all. Still, for a locally produced, locally ...

Get Developing Feeds with RSS and Atom now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.