Listing 2: add-person.html % # Make sure that we got all required name-value pairs % unless ($first_name and $last_name and $country and $email) {
Sorry, but you need to provide us with (at a minimum) the person's first name, last name, country, and e-mail address.
% # Make sure that the e-mail address looks somewhat valid % } elsif ($email !~ /[\w.]+@\w+\.\w{2,3}/) {Sorry, but the provided e-mail address doesn't look legal.
% # If we made it this far, try to create the new person % } else { <%perl> my $success = $people->new_person(first_name => $first_name, last_name => $last_name, country => $country, email => $email); %perl> % if ($success) {We successfully added a new person to the database.
% } else {There was an error trying to add a new person to the database. Here is the method that was invoked:
$people->new_person(first_name => <% $first_name %>, last_name => <% $last_name %>, country => <% $country %>, email => <% $email %>);% } % } <%init> use People; my $people = new People; %init> <%args> $first_name $last_name $address1 $address2 $email $city $state $postal_code $country $comments %args>