.@ Tony Finch – blog


My link log is a fairly horrible combination of three perl scripts. It's "symbiosisware", a quick hack specifically for my needs and not designed for general usage. (I think I got that term from Simon Tatham.) Still, people occasionally ask how it works, so here goes.

The visible part is a 35,000 line CGI script which consists almost entirely of a data structure containing my log of nearly 7000 links. (This is perhaps a bit wasteful - the CGI uses about a quarter of a second of CPU time.) This program produces the HTML web page, the atom feed, and does redirections for the short versions of the URLs. There's also a periodic log analysis job (some vile seddery) which counts how many times each short URL has been requested in the last couple of weeks.

New URLs are added to the CGI script using a command line utility which also feeds the links to IRC, Twitter, and Delicious. (I posted previously about scripting Twitter using Jef Poskanzer's utilities.) This script also chooses the random tag used in the short version of the URL.

Finally, I don't have convenient access to the command line when I am using my iPhone, so I use its build-in facility to mail a link to a particular address. These messages are delivered to a special mailbox (using Sieve) which is polled periodically to extract the links and feed them to the command-line tool. The cron script is mostly a shonky IMAP implementation and RFC 822 message parser...

You can see I'm not particularly fond of digging through CPAN to find which of the million libraries is worth using...