getlocaltime.cgi
#!/usr/bin/perl @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($key, $value) = split (/=/, $pair); $key =~ tr/+/ /; $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~s/<!--(.|\n)*-->//g; if ($formdata{$key}) { $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime(time); %zones = ("EST", 5, "CT", 6, "MT", 7, "PT", 8); $place= $formdata{'place'}; $zone = $formdata{'zone'}; $hour = $hour-$zones{$zone}; if ($hour <= 0) { $hour = $hour +24; } $min=sprintf("%02d", $min); $sec=sprintf("%02d", $sec); print "Content-type: text/html\n\n"; print "According to my server, right now the time in $place is: $hour:$min:$sec";