# expireWhatsNewItems.pl # # Removes expired items from the "What's new" section of my # Agora home page. Updates the page's date if changed. # # Note that this script assumes a very rigid format, with # fixed indentation and spacing in the META tags. Also, # the "What's new" section is expected to be bracketed by # delimiting comments, like so: # # #
a header line # link 1 # ··· link 2 # ··· link 3 #
# # # If all links have expired, this script comments out the section's # header line as well. The quotes around the ISO-format expiration # date are optional. # # Mark L. Irons # 10-11 November 2000 # #-------------------------------------------------------------------- # # Patterns to match # # METADatePattern looks like ' ' # $METADatePattern = '^ '; # # Define section boundaries # $sectionOpenPattern = "^"; $sectionClosePattern = "^"; # # Define expiration date pattern # $expiresPattern = ''; # #-------------------------------------------------------------------- # Get current date and convert it to ISO format # ($s,$m,$h,$curDay,$curMon,$curYear,$w,$y,$d) = localtime; $curYear=$curYear+1900; # living in 21st century $curMon=$curMon+1; # Jan is 1st month, not 0th if ($curMon < 10) { $curMon = "0".$curMon; } # pad month to two digits if ($curDay < 10) { $curDay = "0".$curDay; } # pad day to two digits $curDate = $curYear."-".$curMon."-".$curDay; # put it all together # #-------------------------------------------------------------------- # if (!open(HTMLFILE,"Agora/index.html")) { warn "Can't open file, exiting.\n"; exit; } $modifiedFlag = 0; # haven't changed file $chunk1 = ""; # text before META date $dateline = ""; # META date line $chunk2 = ""; # text between META date and What's new section $whatsNew = ""; # text of What's new section $chunk3 = ""; # text after What's new section while (