
Zeke_D
Deleted
Oct 10, 2000, 8:09 PM
Post #4 of 5
(244 views)
|
|
Re: There has to be a better way!
[In reply to]
|
Can't Post
|
|
Neither of those quite worked for me, I guess I should show you the whole subroutine...... <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> sub hof { $font = "<FONT SIZE='2' color='#$fontcolor'>"; print "<CENTER><TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0' WIDTH='120'><TR><TD COLSPAN='2' ALIGN=CENTER>$font<B>Snippet Contest</B><BR><FONT SIZE='1' face='arial' COLOR='yellow'>Current Top Ten</TD></TR>"; print "<TR><TD WIDTH='50\%'><U>$font Score</TD><TD WIDTH='50\%'><P ALIGN=RIGHT><U>$font Username</TD></TR>"; $num = '0'; until ($num eq '10') { $highscore[$num] = '0'; $num++; open ("USERNAMES", "$dataurl/snippet.user"); @username = <USERNAMES>; foreach (@username) { ($user) = split ('[|]',$_); open ("FILE","$dataurl/data/$user.reg")| |print "cant read userfile"; @file = <FILE>; foreach (@file) { ($xname, $xemail, $xaddress, $xcity, $xstate, $xzip, $xuser, $xpass, $q[1], $q[2], $q[3], $q[4], $q[5], $q[6], $q[7], $q[8], $q[9], $q[10], $q[11], $q[12], $q[13], $q[14], $q[15], $q[16], $q[17], $q[18], $q[19], $q[20], $xguess, $xright, $xscore) = split ('[|]',$_); unless (($xuser eq $user[1])| |($xuser eq $user[2])| |($xuser eq $user[3])| |($xuser eq $user[4])| |($xuser eq $user[5])| |($xuser eq $user[6])| |($xuser eq $user[7])| |($xuser eq $user[8])| |($xuser eq $user[9])| |($xuser eq $user[10])){ if ($xscore > $highscore[$num]) { $highscore[$num] = $xscore ; $user[$num] = $xuser ; } } } } print "<TR><TD WIDTH='50\%'>$font $highscore[$num]</TD><TD WIDTH='50\%'><P ALIGN=RIGHT>$font $user[$num]</TD></TR>"; } print "</TABLE>"; } </pre><HR></BLOCKQUOTE> basically it gets the top ten scores and displays them in a table snippet.user is a userdatabase (pipe delimited) with an asterisk as a placeholder ie " username|* " The sub reads the username and opens the file username.reg (another pipe delimited database) the important variables from the username.reg are $xscore (players score) and $xuser (username) I have it looking to see if that username was already a top ten, if not set their place and those two variables and start over. I am a total newbie, and this is the best I could come up with...... like i said there has to be a better way.....
|