Checkbox Illustration: Digital Clock
#!/usr/bin/perl -w

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

($min, $hour, $mday, $month, $year, $day) = (localtime(time))[1..6];

# Trick to turn months and days of week into human-readable form!!
$month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$month];
$day   = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$day];

$year += 1900;

if (param('Set'))  #  Param -- the most important CGI.pm function!!!!
{
      $time = sprintf("%02d", $hour) if param('hours');
      $time .= sprintf(":%02d", $min) if param('minutes');
      $time .= " $day" if param('day');
      $time .= " $month" if param('month');
      $time .= " $mday" if param('day-of-month');
      $time .= " $year" if param('year');
      print header, start_html, p("The time is: $time"), end_html;
}


print header;
print start_html("Digital Clock!"), h1("Digital Clock!");
print start_form(),
      p("Show: "),
  #  Checked => 0 is the default
      checkbox(-name=>'hours', -checked=>0),
      checkbox(-name=>'minutes', -checked=>0),
      checkbox(-name=>'month', -checked=>0),
      checkbox(-name=>'day-of-month', -checked=>0),
      checkbox(-name=>'day', -checked=>0),
      checkbox(-name=>'year', -checked=>0),
  #  Reset is like "clear current choices"
      p(), reset(-name=>'Reset'), submit(-name => 'Set'), end_form, end_html;