Here's the Perl script that I wrote to process reservations to the Cat and Otter Bistro (see the WAP/WML chapter):
#!/usr/local/bin/perl
use strict;
use CGI ':standard';
print "Content-type: text/vnd.wap.wml\n\n";
print '<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card>';
my $number = param('number');
my $smoke = param('smoke');
my $dinner_index = param('dinner_index');
$number =~ /([0-9]*)/ ;
$number = $1;
if ($number<=0) {
print "<p>You can't make a reservation for 0 (or less) people! Try again.</p>"
} elsif ($number>=1) {
print "<p>Thank you for your reservation. We'll hold a table for ";
if ($number==1) {
print "one person";
} else {
print "$number people";
}
if (lc $smoke eq 'yes') {
print " in the smoking section. ";
} else {
print " in the non-smoking section. ";
}
my @entrees = ('Chicken Parmesian', 'Filet Mignon', 'Veal Cutlets', 'Seafood Fideua', 'Rice and Beans', 'Pasta Primavera', 'Spinach Ravioli');
if (1 <= $dinner_index && $dinner_index <= 7) {
$dinner_index--;
print "And we'll save you some @entrees[$dinner_index].";
}
}
print '</p><do type="accept">
<go href="http://www.cookwood.com/html5ed/examples/wap_wml/complete.wml" />
</do></card></wml>';