Last-Modified Files

There are lots of reasons to have an ever-updating list of recently modified files: security, for one. However, it’s also a useful system for helping you group working files in your mind. I’m forever loosing track of files I’m working on—especially overnight—and this feed helps a great deal. For collaborative working, it’s a godsend because you can see what other activity is going on automatically. I also have one of these pointed at a shared directory where friends drop music and silly MPEGs. Altogether, for something so simple, it’s remarkably useful.

It’s a CGI script that takes a single parameter path, which should be equal to the absolute path on your filesystem that you wish to look under—for example, http://www.example.org/lastmodified.cgi?path=/users/ben.

Walking Through the Code

Let’s trek once again into the warnings;, strict;, XML::RSS, and CGI, plus Date::Manip for the dateline and File::Find for its directory traversing capabilities. Lovely. All set? Good.

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

By now you should be getting the hang of this. We’re firing up the CGI module, snaffling the parameter we are passing to it, then setting up the feed. No great mystery here, in other words. Really, this is somewhat the point: feeds are very simple things. It’s the ideas of how to use them that are valuable.

my $cgi = CGI::new( ); my $start_directory = $cgi->param('path'); my $rss = new XML::RSS( version ...

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.