Code:
#!/usr/bin/perl #
$targetnumba = 3 ;
open (HTML,">keyword.html");
print HTML"<HTML><HEAD><TITLE>Keyword List Html Build</TITLE></HEAD><body><center>";
print HTML"<br><br><a href=keyword.cgi>Build Keywords</a><br><br>";
print HTML"<table width=600 border=2 cellpadding=5 cellspacing=5><tr><td valign=top>Keyword</td><td valign=top>Number of Searches</td></tr>";
open (DATABASE,"<keywords.txt");
@database_in=<DATABASE>;
#foreach $_ (@database_in)
#{
#($name,$numba)=split(/\:/);
#if($numba > $targetnumba){
#print HTML"<tr><td valign=top><font color=RED><b><em>$name</font></em></b></td><td valign=top><font color=RED><b><em>$numba</font></em></b></td></tr>";
#}
#else {
#print HTML"<tr><td valign=top>$name </td><td valign=top><font color=BLUE>$numba</font></td></tr>";
#}
#}
while DATABASE {
push (@database_in, $_);
}
sort NumberSort (@database_in);
@result = split(/\:/,@database_in);
$name = $result[0];
$numba = $result[1];
if($numba > $targetnumba){
print HTML"<tr><td valign=top><font color=RED><b><em>$name</font></em></b></td><td valign=top><font color=RED><b><em>$numba</font></em></b></td></tr>";
}
else {
print HTML"<tr><td valign=top>$name </td><td valign=top><font color=BLUE>$numba</font></td></tr>";
}
}
print HTML"</center></table><br><br></body></html>";
close (HTML);
print "Content-Type: text/html\n\n";
print "<HTML><HEAD><TITLE>Keyword List Html Build</TITLE></HEAD><body link=red vlink=red bgcolor=ffffff text=000000><center>";
print "<br><br>";
print "Finished Sorting / Building Building Keywords HTML Page";
print "<br><br>";
print "<br><br>";
print "<a href=keyword.html>Go to Keywords</a>";
print "<br><br>";
print "<br><br>";
print "</center></body></html>";
sub NumberSort {
# ------------------------
# sort's numbers
if($a < $b) { return -1; }
elsif($a == $b) { return 0; }
else { return 1; }
}
I have some commented lines in there that worked with my previous script.. Now I'm trying to get it to sort the second field in the db , the number field , and print to the keyword.html in numerical order from HIGHEST to LOWEST number. I can't figure it out.. Can someone PLEASE help me!!!
Thanx in Advance!
------------------
The Crowe crowe@darkspiral.com
http://www.darkspiral.com