------------------------------------------------------------ Listing 4: edit-person.html % # Make sure that we got all required name-value pairs % unless ($email and $new_first) {
Sorry, but you need to provide us with the person's e-mail address and their new first name.
% # 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, use $email to choose the person, then % # change the first name with the API % } else { <%perl> my $set_person_successfully = $people->set_current_person_by_email($email); %perl> % if ($set_person_successfully) { <%perl> my $updated_name_successfully = $people->update_first_name($new_first); %perl> % if ($updated_name_successfully) {You successfully changed the first name.
% } else {There was an error trying to set the name for "<% $email %>" to "<% $new_first %>".
% } % } else {There was an error trying to set the current person based on the e-mail address "<% $email %>".
% } % } <%init> use People; my $people = new People; %init> <%args> $email $new_first %args>