📄 ch17.htm
字号:
chop;
<BR>
@shortline
= split(/\t/);<BR>
if
( ($shortline[0] eq $field[0]) &&<BR>
($shortline[1]
eq $field[1]) ) {<BR>
$stdev
+= ($shortline[2] - $average)**2;<BR>
$n++;
<BR>
}
<BR>
}<BR>
close(CDD);
<BR>
}<BR>
$stdev = ($stdev / $n)**0.5;
<BR>
<BR>
$shortcutname = &hash($field[0],$field[1]);
<BR>
print "<TD ALIGN=LEFT
VALIGN=TOP><A NAME=\"$shortcutname\">$field[0]</A>",
<BR>
"</TD>\n";
<BR>
print "<TD ALIGN=LEFT
VALIGN=TOP>$field[1]</TD>\n";<BR>
print "<TD ALIGN=LEFT
VALIGN=TOP>$field[3]</TD>\n";<BR>
printf("<TD ALIGN=LEFT
VALIGN=TOP>%5.2f</TD>\n",$field[4]/$field[3]);<BR>
printf("<TD ALIGN=LEFT
VALIGN=TOP>%7.4f</TD></TR>\n",$stdev);<BR>
}<BR>
print "</TABLE>\n";<BR>
<BR>
#<BR>
# Now, output a graph of how many votes an artist got... I'm not
sure<BR>
# what the statistical significance of this would but, but it'll
look cool,<BR>
# and also show how graphs can be produced<BR>
#<BR>
print "<H3>Graph of Vote Points Per
Artist</H3>\n<PRE>\n";<BR>
$maxkeylength = -1;<BR>
foreach ( @line ) {<BR>
@field = split(/\t/,$_,5);
<BR>
$votes{$field[0]} += $field[4];
<BR>
$maxkeylength = length($field[0])
if length($field[0]) > $maxkeylength;<BR>
}<BR>
$maxvotes = -1;<BR>
foreach ( values(%votes) ) { $maxvotes = $_
if $_ > $maxvotes; }<BR>
foreach ( sort by_votes keys(%votes) ) {<BR>
printf("%${maxkeylength}s :
",$_);<BR>
$i = 1;<BR>
$numstars = 30 * $votes{$_}
/ $maxvotes;<BR>
$numstars = int(++$numstars)
if ( ($numstars - int($numstars)) >= 0.5);<BR>
while ( $i <= $numstars
) {<BR>
print "*";
<BR>
$i++;<BR>
}<BR>
print " $votes{$_} vote
points\n";<BR>
}<BR>
print <<END;<BR>
</PRE><BR>
<P><BR>
Return to <A HREF=$ref_url>Home Page</A><BR>
</BODY></HTML><BR>
END<BR>
}<BR>
<BR>
sub reg_user {<BR>
<BR>
#<BR>
# - open user file corresponding to the email address / password
pair provided<BR>
# - display error page if file can't be found or email/password
don't match<BR>
# - create @userfile array containing each line in the .cdd data
file <BR>
#<BR>
$userfilename = $tokens{'password'} . '.cdd';
<BR>
&password_error if ( !(-e $userfilename)
);<BR>
open(UF,$userfilename);<BR>
chop(@userfile = <UF>);<BR>
close(UF);<BR>
($email,$passwd) = splice(@userfile,0,2); #
remove 1st 2 entries<BR>
($discard,$keep) = split(/\t/,$email);<BR>
&password_error if ( $tokens{'email'} ne
$keep);<BR>
@userfile = sort @userfile;<BR>
<BR>
#<BR>
# Construct @line array of all entries and @shortlist array for
shortlisted<BR>
# entries. Then, sort these two arrays alphabetically
<BR>
#<BR>
open(CD,"cd.txt");<BR>
while ( <CD> ) {<BR>
chop;<BR>
@field = split(/\t/,$_,5);
<BR>
push(@line,$_);<BR>
push(@shortlist,$_) if $field[2]
eq '*';<BR>
}<BR>
close(CD);<BR>
@line = sort @line;<BR>
@shortlist = sort @shortlist;<BR>
<BR>
print "Content-type: text/html\n\n";
<BR>
print "<HTML>\n<HEAD><TITLE>Here
is your voting profile</TITLE></HEAD>\n" ,<BR>
"<BODY>\n<H3>Voting Profile
of user <I>$tokens{'email'}</I></H3>\n"
,<BR>
"<P>To re-cast or remove votes, use
the appropriate selection menus " ,<BR>
" and submit the form.\n";<BR>
<BR>
print "<FORM ACTION=$ref_url METHOD=POST>\n";
<BR>
print "<INPUT TYPE=HIDDEN NAME=\"email\"
VALUE=$tokens{'email'}>\n";<BR>
print "<INPUT TYPE=HIDDEN NAME=\"password\"
VALUE=$tokens{'password'}>\n";<BR>
print "<INPUT TYPE=SUBMIT NAME=\"submit\"
VALUE=\"Submit these Votes\">\n";<BR>
print "<INPUT TYPE=RESET VALUE=\"Reset
form to its original values\">\n";<BR>
print "<P><TABLE BORDER>\n";
<BR>
<BR>
print "<TR><TH VALIGN=TOP NOWRAP
COLSPAN=3>Short-listed Albums currently",<BR>
" Voted Upon</TH></TR>\n";
<BR>
print "<TR><TH VALIGN=TOP NOWRAP>Artist</TH><TH
VALIGN=TOP NOWRAP>Album",<BR>
"</TH><TH VALIGN=TOP>Your Vote</TH>\n";
<BR>
<BR>
#<BR>
# The following loop goes through all entries in the userfile
which <BR>
# correspond with short-listed entries in the album database
<BR>
#<BR>
foreach $userline ( @userfile ) {<BR>
@field = split(/\t/,$userline);
<BR>
$shortflag = 0;<BR>
foreach $shortentry ( @shortlist
) {<BR>
@shortfield
= split(/\t/,$shortentry,5);<BR>
if ( ($shortfield[0]
eq $field[0]) && ($shortfield[1] eq $field[1]) ) {<BR>
$shortflag
= 1;<BR>
$shortentry
= 'DONE';<BR>
$userline
= 'DONE';<BR>
}<BR>
}<BR>
next if $shortflag == 0;<BR>
print "<TR>\n<TD
ALIGN=LEFT VALIGN=CENTER NOWRAP>$field[0]</TD>\n";
<BR>
print "<TD ALIGN=LEFT
VALIGN=CENTER NOWRAP>$field[1]</TD>\n";<BR>
$namehash = &hash($field[0],$field[1]);
<BR>
print "<TD ALIGN=LEFT
VALIGN=CENTER><SELECT NAME=$namehash>\n";<BR>
print "<OPTION>[remove
vote]</OPTION>\n";<BR>
$select{$field[2]} = ' SELECTED';
<BR>
for $i (0..10) {<BR>
print "<OPTION$select{$i}>$i</OPTION>\n";
<BR>
}<BR>
undef(%select);<BR>
<BR>
print "</SELECT></TD></TR>\n";
<BR>
}<BR>
<BR>
print "<TR><TH VALIGN=TOP
NOWRAP COLSPAN=3>Other Short-listed Albums",<BR>
"</TH></TR>\n";
<BR>
print "<TR><TH VALIGN=TOP
NOWRAP>Artist</TH><TH VALIGN=TOP NOWRAP>Album",
<BR>
"</TH><TH VALIGN=TOP>Your
Vote</TH>\n";<BR>
<BR>
#<BR>
# do the same for each short-list item not already encountered,
as marked<BR>
# by the DONE flag... notice that now I don't have to use any
special<BR>
# code to determine what OPTION to mark as SELECTED<BR>
#<BR>
foreach ( @shortlist ) {<BR>
next if $_ eq 'DONE';<BR>
@field = split(/\t/,$_,5);
<BR>
print "<TR>\n<TD
ALIGN=LEFT VALIGN=CENTER NOWRAP>$field[0]</TD>\n";
<BR>
print "<TD ALIGN=LEFT
VALIGN=CENTER NOWRAP>$field[1]</TD>\n";<BR>
$namehash = &hash($field[0],$field[1]);
<BR>
print "<TD ALIGN=LEFT
VALIGN=CENTER><SELECT NAME=$namehash>\n";<BR>
print "<OPTION SELECTED>[no
current vote]</OPTION>\n";<BR>
for $i (0..10) {<BR>
print "<OPTION>$i</OPTION>\n";
<BR>
}<BR>
print "</SELECT></TD></TR>\n";
<BR>
}<BR>
<BR>
print "<TR><TH VALIGN=TOP NOWRAP
COLSPAN=3>Long-listed Albums currently",<BR>
" Voted Upon</TH></TR>\n";
<BR>
print "<TR><TH VALIGN=TOP NOWRAP>Artist</TH><TH
VALIGN=TOP NOWRAP>Album",<BR>
"</TH><TH VALIGN=TOP>Your Vote</TH>\n";
<BR>
<BR>
#<BR>
# do the same for already voted-upon long-listed entries... all
short-listed <BR>
# entries will be listed as DONE so skip<BR>
#<BR>
foreach $userline ( @userfile ) {<BR>
next if $userline eq "DONE";
<BR>
@field = split(/\t/,$userline);
<BR>
$userline = "DONE";
<BR>
foreach $entry ( @line ) {
<BR>
@entryfield
= split(/\t/,$entry,5);<BR>
if ( ($entryfield[0]
eq $field[0]) && ($entryfield[1] eq $field[1]) )<BR>
{ $entry
= "DONE"; }<BR>
}<BR>
print "<TR>\n<TD
ALIGN=LEFT VALIGN=CENTER NOWRAP>$field[0]</TD>\n";
<BR>
print "<TD ALIGN=LEFT
VALIGN=CENTER NOWRAP>$field[1]</TD>\n";<BR>
$namehash = &hash($field[0],$field[1]);
<BR>
print "<TD ALIGN=LEFT
VALIGN=CENTER><SELECT NAME=$namehash>\n";<BR>
print "<OPTION>[remove
vote]</OPTION>\n";<BR>
$select{$field[2]} = ' SELECTED';
<BR>
for $i (0..10) {<BR>
print "<OPTION$select{$i}>$i</OPTION>\n";
<BR>
}<BR>
undef(%select);<BR>
<BR>
print "</SELECT></TD></TR>\n";
<BR>
}<BR>
print "<TR><TH VALIGN=TOP NOWRAP
COLSPAN=3>Other Long-listed Albums",<BR>
"</TH></TR>\n";<BR>
print "<TR><TH VALIGN=TOP NOWRAP>Artist</TH><TH
VALIGN=TOP NOWRAP>Album",<BR>
"</TH><TH VALIGN=TOP>Your Vote</TH>\n";
<BR>
<BR>
#<BR>
# do the same for not voted-upon long-listed entries... all short-listed
<BR>
# and voted-upon entries will be listed as DONE so skip... note,
no fancy<BR>
# code to determine which OPTION to mark as SELECTED<BR>
#<BR>
foreach $entry ( @line ) {<BR>
next if $entry eq "DONE";
<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -