Simpler TODO RSS feed

Here's a simpler version of Ben Hammersley's RSS feed generator for TODO items - I use it alongside my lab weblog to keep track of things to follow up from previous experiments. This version removes some of the dependencies by not requiring any XML parsers to be installed.


#!/usr/bin/perl -w
# RSS generator for Code TODO comments
# Original version by Ben Hammersley
# at http://www.benhammersley.com/code/code_todo_lines_to_rss.html
use strict;
use File::Find;
# y'all be wanting to change the next line
my $start_directory = "/Library/WebServer/Documents/blosxom/docs/";
print <<HEADER;
Content-type: application/xml+rss
<?xml version="1.0" encoding="UTF-8"?>
<rss version="0.91">
<channel>
<title>TODO</title>
<link></link>
<description></description>
HEADER
    
find (\&search_and_rss, $start_directory);
sub search_and_rss {
    my $file = $File::Find::name;
    open (CODEFILE, "< $file");
    
    while (<CODEFILE>) {
        if ($_ =~ m/TODO/) {
        
            print qq|
            <item>
                <title>$file</title>
                <link>file://$file</link>
                <description>$_ at Line $. of $file"</description>
            </item>
            |;
    
        }
    } 
    close (CODEFILE);
}
print '</channel></rss>';