in reply to erm... I need help!
#!/usr/bin/perl -w use strict; my $memberListFile = "members.txt"; my $hits; my %rank; my $user; my $email; my $username; my $sitename; my $url; my $button; my $desc; print "Content-type:text/html\n\n"; open(USERS, $memberListFile) die ("can't open $memberListFile: $!"); while(<USERS>) { chomp; # ah, cleverly working on $_ ($user,$email) = split(/\|/); my $USR; # better find some naming conventions, for me looks this +like a CONSTANT in the source $user .= ".txt"; # still ugly, but better compose filenames before + using them (makes debugging easier) open (USR,"$user") or die ("can't open $user: $!"); $USR = <USR>; # scalar context ? why? do all these files only have + one line? close(USR); ($username, $sitename, $url, $email, $button, $desc, $hits) = spli +t(/\|/, $USR); $rank{$username} = { 'url' => $url, 'email' => $email, 'button' => $button, 'desc' => $desc, 'hits' => $hits, 'sitename' => $sitename, 'user' => $username }; } print <<eof; <font face="verdana" color="black"> <table WIDTH="75%" border="1" bordercolor="black" cellSpacing="0" cell +Padding="0" align="center"> <tr bgcolor="#000080"> <th> <font face="verdana" color="white"> Site </font> </th> <th> <font face="verdana" color="white"> button </font> </th> <th> <font face="verdana" color="white"> Hits </font> </th> </tr> eof foreach (sort {$rank{$b}{'hits'} <=> $rank{$a}{'hits'}} keys %rank) { # oh ouh here it is not clever to work with $_ print <<eof; <tr> <td align="center"> <b> <a href="$rank{$_}{url}"> $rank{$_}{sitename} </a> <br /> <font face="verdana" size="1"> $rank{$_}{desc} </font> </b> </td> <td align="center" width="88"> <img src="$rank{$_}{button}" height="31" width="88"> </td> <td align="center"> $rank{$_}{hits} </td> </tr> eof } print "</table>\n</font>";
|
---|