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) { Missing information!

Missing information!

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}/) { Bad e-mail address!

Bad e-mail address!

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); % if ($success) { Sucess!

Success!

We successfully added a new person to the database.

% } else { Error!

Error!

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; <%args> $first_name $last_name $address1 $address2 $email $city $state $postal_code $country $comments