#! /usr/local/bin/perl # datepage.pl - by David Efflandt - 9/24/95 [9/30/95] # # Run this script in UNIX after updating any html files. # Any line beginning with $tag will be replaced with $update unless equal. # Nothing will change if the $tag line matches the current file date. # # NOTE: Move any html tags to a separate line including

or
. # # Example: # # This line will be replace with current update ### ### Change this to the string you want ending the line with a space. ### Tag prefix and date suffix will be added. $update_string = "This page was last updated "; ### Change this to your list of Web pages to update ### Use relative path from script or full path. ### Surround each file with single quotes and follow with comma. @list = ( 'index.html', 'pub/index.html', ); ### You should not have to change anything below this line ### # The line in each file that begins with the tag in quotes will be replaced $tag = ''; # Get number of lines in file and old date line print "\n"; print "Checking update string in Web pages\n\n"; foreach $file (@list) { open (PAGE,"<$file") || warn "Can't open $file: $!\n"; @lines = ; close(PAGE); $lines = @lines; next unless ($olddate = (grep (/$tag/, @lines))[0]); # Get current file date and update line ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst ) = localtime(time - int((-M $file) * 86400)); ++$mon; # increment because January is zero $date = "$mon/$mday/$year"; $update = $tag . $update_string . $date . "\n"; # Do nothing if olddate and update are the same if ($olddate eq $update) { print "$file remains at $date\n"; next; } # Open file to output open (PAGE,">$file"); for ($i=0;$i<=$lines;$i++) { $_=$lines[$i]; if (/$tag/) { print PAGE $update; print "$file has been updated to $date\n"; } else { print PAGE $_; } } close (PAGE); }