#!/usr/bin/perl -w
########
# example of function-oriented use of CGI.pm
#
# more examples at 
# http://bob.marlboro.edu/~msie/2001/ipl/perl/code/jan13/
#
#############

use strict;
use CGI qw(:standard);			# read cgi parameters, import functions
use CGI::Carp qw(fatalsToBrowser); 

my $who = param('who');			# returns "Bob" if ?who=BOB in URL
					# or if parameter "who" in form

my $forJimHTML = "";
if ($who =~ /jim/i) {
  $forJimHTML = "<hr><b>Hi Jim!</b><hr>";
}

my $whoHTML  = "";
if ($who){
  $whoHTML =   "Your name is '$who'.<hr>";
}

print 
  header,				# http header - set cookie here
  start_html,				# <html>, <head>, <title>, <bod> tags
  $whoHTML,
  start_form,				# <form> tag
  "Please input your name : ",
  textfield( -name    => "who",		# text box
	     -default => "",
	     -size    => 16,
	   ),
  end_form,
  $forJimHTML,
  end_html,
  ;
