#!/usr/bin/perl -w # Name : Perl Welcome Message # Author : Terrence Ma # Email : terrence@terrence.com # Web : http://www.terrence.com # Date : 06/03/2001 # License : GNU GPL - http://www.gnu.org/copyleft/gpl.html # Warranty : No Warranty # use lib use 5; use strict; use CGI::Pretty; # init variables my $cgi = new CGI; my $title = "Perl Welcome Message"; my $source = "http://www.terrence.com/perl/welcome/welcome.txt"; my $username; my $time; my $response; # if no parameter, print request page # else print response page # print request page if (!$cgi->param()) { # print header print $cgi->header(), $cgi->start_html($title); print $cgi->h1($title), $cgi->hr(), $cgi->br(); # print body print $cgi->start_form(), $cgi->font("Please enter your name :"), $cgi->textfield(-name=>"username", -value=>"Anonymous", -size=>"20"), $cgi->submit(-value=>"Submit"), $cgi->end_form(); # print footer print $cgi->hr(), $cgi->a({-href=>$source}, "Program Source"), $cgi->br(), $cgi->end_html(); exit(0); # else print response page } else { # get $username, $time # build $response $username = $cgi->param("username"); $time = scalar localtime; $response = ""; $response .= "Hello $username, welcome to this web page !\n\n"; $response .= "Time is now $time."; # print header print $cgi->header(), $cgi->start_html($title); print $cgi->h1($title), $cgi->hr(), $cgi->br(); # print body print $cgi->font({-color=>"#0000ff"}, $cgi->pre($response)); # print footer print $cgi->hr(), $cgi->a({-href=>$source}, "Program Source"), $cgi->br(), $cgi->end_html(); exit(0); }