I made this after strandardt Top 10 sub don't show me one string which should be showed. Standardt sub build_rate_page very comlex for understand so I made myself:
sub build_rate_page {
# --------------------------------------------------------
# Creates a Top 10 ratings page.
my (@values, $id, $votes, $rate, @top_votes, @top_rate);
local ($top_rated, $top_votes);
if ($build_ratings_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;
open (LINKS, $db_links_name) or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
LINE: while (<LINKS>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
$votes = $values[$db_votes];
$rate = $values[$db_rating];
next if ($votes < 10);
if (($#top_votes < 9) or ($votes > $$top_votes[$#top_votes])) {
push (@top_votes, [$votes,@values]);
if ($#top_votes < 9) {
@top_votes = sort { $$b[0] <=> $$a[0] } @top_votes;
}
else {
shift(@top_votes);
}
}
if (($#top_rate < 9) or ($rate > $top_rate[$#top_rate])) {
push (@top_rate, [$rate,@values]);
if ($#top_rate <= 9) {
@top_rate = sort { $$b[0] <=> $$a[0] } @top_rate;
}
else {
shift(@top_rate)
}
}
}
close LINKS;
$top_rated = ''; $top_votes = '';
foreach (sort { $b <=> $a } @top_votes) {
$top_votes .= qq~<tr><td align=center>@{$_}[$db_rating+1]</td><td align=center>@{$_}[$db_votes+1]</td><td>
<a href="@{$_}[$db_url+1]">@{$_}[2]</a></td></tr>\n~;
}
foreach (sort { $b <=> $a } @top_rate) {
$top_rated .= qq~<tr><td align=center>@{$_}[$db_rating+1]</td><td align=center>@{$_}[$db_votes+1]</td><td>
<a href="@{$_}[$db_url+1]">@{$_}[2]</a></td></tr>\n~;
}
open (RATE, ">$build_ratings_path/$build_index") or &cgierr ("unable to open top rated page: $build_ratings_path/$build_index. Reason: $!");
print "\tVote Range: $top_votes[0][0] .. $top_votes[$#top_votes][0]\n";
print "\tRate Range: $top_rate[0][0] .. $top_rate[$#top_rate][0]\n";
print RATE &site_html_ratings;
close RATE;
}
If anyone would be test and find error please tell me.
sub build_rate_page {
# --------------------------------------------------------
# Creates a Top 10 ratings page.
my (@values, $id, $votes, $rate, @top_votes, @top_rate);
local ($top_rated, $top_votes);
if ($build_ratings_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;
open (LINKS, $db_links_name) or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
LINE: while (<LINKS>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
$votes = $values[$db_votes];
$rate = $values[$db_rating];
next if ($votes < 10);
if (($#top_votes < 9) or ($votes > $$top_votes[$#top_votes])) {
push (@top_votes, [$votes,@values]);
if ($#top_votes < 9) {
@top_votes = sort { $$b[0] <=> $$a[0] } @top_votes;
}
else {
shift(@top_votes);
}
}
if (($#top_rate < 9) or ($rate > $top_rate[$#top_rate])) {
push (@top_rate, [$rate,@values]);
if ($#top_rate <= 9) {
@top_rate = sort { $$b[0] <=> $$a[0] } @top_rate;
}
else {
shift(@top_rate)
}
}
}
close LINKS;
$top_rated = ''; $top_votes = '';
foreach (sort { $b <=> $a } @top_votes) {
$top_votes .= qq~<tr><td align=center>@{$_}[$db_rating+1]</td><td align=center>@{$_}[$db_votes+1]</td><td>
<a href="@{$_}[$db_url+1]">@{$_}[2]</a></td></tr>\n~;
}
foreach (sort { $b <=> $a } @top_rate) {
$top_rated .= qq~<tr><td align=center>@{$_}[$db_rating+1]</td><td align=center>@{$_}[$db_votes+1]</td><td>
<a href="@{$_}[$db_url+1]">@{$_}[2]</a></td></tr>\n~;
}
open (RATE, ">$build_ratings_path/$build_index") or &cgierr ("unable to open top rated page: $build_ratings_path/$build_index. Reason: $!");
print "\tVote Range: $top_votes[0][0] .. $top_votes[$#top_votes][0]\n";
print "\tRate Range: $top_rate[0][0] .. $top_rate[$#top_rate][0]\n";
print RATE &site_html_ratings;
close RATE;
}
If anyone would be test and find error please tell me.