#!/usr/local/bin/perl -w
#
# news.cgi
#
# Logs click-throughs on URLS of the form:
# http://sitename/news.cgi?msgid=20000415
# where the number at the end is a unique id used to
# find and display a web page.

use strict;
use CGI qw/:standard/;

# Build and return the url to the user
my $msgid = param('msgid');
my $url = "http://sitename/$msgid.html";
print redirect($url);

# Add to the log file
my $hostname = remote_host();
my $logfile = '/full/path/to/logfile.txt';
open LOG, ">>$logfile" or die "news.cgi: Unable to open $logfile\n";
print LOG "$hostname - $msgid\n";
close LOG;