
#!/usr/local/bin/perl
# Script: calendar1.pl
$CAL='/usr/bin/cal';
$DATE='/bin/date';

# Fetch the current year using the Unix date
# command
# On this Sun system, the date command doesn't accept
# the %Y format, so we do a pattern match to fetch
# the current year.
chop($date=`$DATE`);
($year)=$date=~/(\d+)$/;        # get rid of all but the year part

# Fetch the text of the calendar using the cal
# command
chop($calendar_text=`$CAL $year`);

# Print it all out now
print <<END;
Content-type: text/html

<HTML><HEAD>
<TITLE>Calendar for Year $year</TITLE>
</HEAD><BODY>
<H1>Calendar for Year $year</H1>
<PRE>
$calendar_text
</PRE>
<HR>
<A HREF="/">Welcome Page</A>
</BODY></HTML>
END

