Skip to Main Content
Developing Feeds with RSS and Atom
book

Developing Feeds with RSS and Atom

by Ben Hammersley
April 2005
Intermediate to advanced content levelIntermediate to advanced
270 pages
7h 13m
English
O'Reilly Media, Inc.
Content preview from Developing Feeds with RSS and Atom

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How to Build an RSS 2.0 Feed

How to Build an RSS 2.0 Feed

Mark Woodman
Secrets of RSS

Secrets of RSS

Steven Holzner

Publisher Resources

ISBN: 0596008813Supplemental ContentErrata Page