#!/usr/local/bin/perl # File: calendar2.pl $CAL='/usr/bin/cal'; # Print the header print "Content-type: text/html\n\n"; # Print the top of the document, including an tag print <Calendar

Calendar

Enter the years you want to display calendars for, separating each year by a space. For example "1992 1993". END # Try to fetch the list of years from the # query string. This is a keyword-list style # script, so we can find it in @ARGV. For # sanity-checking, make sure that everything # in @ARGV looks like a year and ignore everything else. foreach (@ARGV) { next unless /(\d{4})/; # pattern match for 4 digits push(@years,$1); # push the year onto an array } # If @years is empty, then either the query string was # empty or it contained nothing that looked like a year. # Fetch the current year using the Unix date command unless (@years) { chop($year=`date +%Y`); push(@years,$year); } # Loop over the years. foreach $year (@years) { chop($calendar_text=`$CAL $year`); print <Calendar for Year $year
$calendar_text
END ; } # End it now print < Welcome Page END