-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.pl
executable file
·37 lines (25 loc) · 919 Bytes
/
auth.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/local/bin/perl -w
use strict;
use DBI;
use CGI qw(escape unescape);
use lib "/usr/local/www/server/library/cgi-bin";
use MrsAbbott;
my $authorID = '69';
my ($firstName, $lastName) = getAuthorInfo ($authorID);
my $authorName = formatAuthorName ($firstName, $lastName);
my $newFirstName = 'John';
my $newLastName = 'Smith';
my $newAuthorName = formatAuthorName ($newFirstName, $newLastName);
my $isKnownID = findAuthorByNames ($newFirstName, $newLastName);
my $rowsAffected;
if ($isKnownID) {
print "<p>$newAuthorName is known (ID $isKnownID).\n",
$rowsAffected = replaceAuthor ($authorID, $isKnownID);
$authorID = $isKnownID;
} else {
print "<p>$newAuthorName is a new author! ";
$rowsAffected = editAuthorName
($authorID, $newFirstName, $newLastName);
}
print "Replaced ($rowsAffected rows affected).\n";
print "$authorName changed to <b>$newAuthorName</b>.</p>\n";