cityinfo.cgi
#!/usr/bin/perl if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); if ($ENV{'QUERY_STRING'}) { @getpairs =split(/&/, $ENV{'QUERY_STRING'}); push(@pairs,@getpairs); } } else { print "Content-type: text/html\n\n"; print "<P>Use Post or Get"; } print "Content-type: text/html\n\n"; if ($formdata{'infotype'} eq 'time') { %zones=('Hartford', 5, 'Dallas', 6, 'Denver', 7, 'Eureka', 8); $city=$formdata{'city'}; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime(time); $hour = $hour-$zones{$city}; if ($hour <= 0) { $hour = $hour +24; } $min=sprintf("%02d", $min); $sec=sprintf("%02d", $sec); print "<P>The local time in $city is $hour:$min:$sec"; } else { print "<P>I haven't written that part of the program yet. Sorry."; }