1) Ask a user to input their name into a textfield and to choose a color from a popup menu. Then display a page with a short message (e.g. "Thank you $name for your request") in that color. a) Form:
Type in your name, please:

b) CGI Script: #!/usr/local/bin/perl -w use CGI qw(:standard); $name = param("name"); $color = param("color"); print header(); print "User Preferences Thank you $name for your request. "; 2) In the previous script check whether the input is reasonable and not empty: - check whether the name and color contain only word characters or -. - check that neither name nor color is longer than 100 chars (use the {100,} multiplier). If the criteria are not fulfilled, do not display the results page but instead show an error message. if ($name =~ /[^\w-]/ or $color =~ /[^\w-]/ or $name =~ /.{100,}/ or $color =~ /.{100,}/ or $name eq "" or $color eq "") { print header(); print "Invalid input"; die; } 3) For the $name variable replace HTML characters "<" and ">" with < and > before printing the name. (Note: if this is combined with exercise 2, the regular expression for $name must be changed to $name =~ /[^&#;\w-]/ otherwise it would die anyway if it sees HTML tags.) #!/usr/local/bin/perl -w use CGI qw(:standard); $name = param("name"); $color = param("color"); $name =~ s//>/g; if ($name =~ /[^&#;\w-]/ or $color =~ /[^\w-]/ or $name =~ /.{100,}/ or $color =~ /.{100,}/ or $name eq "" or $color eq "") { print header(); print "Invalid input"; die; } print header(); print "User Preferences Thank you $name for your request. "; 5) Change the subroutine "search" so that it actually searches for the keyword and prints the lines that contain the keyword. sub search{ ($term,@text) = @_; print "

The results for $term are:

"; foreach $line (@text){ if ($line =~ /$term/i) { print "$line
"; } } }