Listing 7.4. CGI program to display the guest list.
#!/public/bin/perl5 use CGI::Form; $q = new CGI::Form; print $q->header(); print $q->start_html(-title=>`Guest List'); print "<H1>Guest List</H1>\n"; print "<TABLE BORDER>\n"; print "<TR><TH>Name<TH>Title<TH>Company<TH>Address<TH>City<TH>State<TH>Zip"; print "<TH>Phone<TH>Fax<TH>e-mail<TH>How they heard<TH>Products of interest"; print "<TH>Comments"; open(DATABASE,"< guests.list") || die "Cannot open guest list database for read!\n"; while(<DATABASE>) { print "<TR>\n"; print "<TD>"; @fields=split(/\<\*\>/); print join(`<TD>`,@fields); print "</TR>"; } close(DATABASE); print "</TABLE>";
Figure 7.2.
The table of guests in the guest book.
Review
What you've seen in this section is how to implement your own guest book and the ease with which it can be done using Perl5 and the WWW libraries. You should also consider adding some nice images to your guest book. You should use everything that HTML offers to provide a nice experience for your visitor.
by
updated