# updateFooterDates.pl # # Process a list of HTML files, checking their internal last # updated META tag (NAME="date"). If the value of the date in # the page footer is earlier, change it to the META date. # # Assumption: the META tag will precede the page footer. This # is a safe assumption, since the META tag should be in the #
section and the footer should be in the . # Note that the footer date pattern is very specific. See # code for details. # # The date tag must have this format: # # # # The date in the META tag must be in ISO format, e.g. 2001-11-26 # is 26 November, 2001. # # The "last updated" line in the footer must have this format: # #Last updated dd month year
#
# e.g.,
Last updated 26 November 2001
. The date on
# this line can be either 1 or 2 digits.
#
# Input: a list of files to process.
#
# Mark L. Irons
# 18 July 2000
#
#--------------------------------------------------------------------
# Array of months
#
@months = ('January','February','March','April','May','June',
'July','August','September','October','November','December');
#
#--------------------------------------------------------------------
#
# Patterns to match.
#
# METADatePattern looks like ''
#
$METADatePattern = '';
#
# footerDatePattern looks like '
Last updated 17 July 2000
'
#
$footerDatePattern = '^(
Last updated )(\d\d? [A-Z][a-z]+ \d\d\d\d)(
)$';
#
#--------------------------------------------------------------------
# Loop over files, processing each.
#
while (<>) {
$filename = $_;
if (!open(HTMLFILE,$filename)) {
chop $filename;
warn "Can't open $filename, skipping: $!\n";
next;
}
$modifiedFlag = 0; # haven't changed file
$modifiedFile = ""; # text of modified file
$readableDate = "";
while (