Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

katgirl's scratchpad

by katgirl (Hermit)
on Jun 01, 2004 at 23:42 UTC ( [id://358835]=scratchpad: print w/replies, xml ) Need Help??

This code is called at http://www.queenfans.com/topsites. If someone presses the search button, a line is added to the data file - search|ip address|time stamp - and the following code counts how many times a search has been used. But some people are pressing the button more than once on purpose to push a search to the top... how do I stop this from showing up?
#!/usr/bin/perl print "Content-type: text/html\n\n"; open (TXTFILE, "Searches.dat"); @lines = <TXTFILE>; close(TXTFILE); chomp(@lines); my %seen_hash; my $key_nums =0; foreach $line(@lines){ @data = split(/\|/, $line); push(@searches, $data[0]); } foreach (@searches) { $seen_hash{$_}++; } my @sorted_keys = sort { $seen_hash{ $b } <=> $seen_hash{ $a } } keys + %seen_hash; print "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; # then just do a print for each key in the %seen_hash hash $rows = 0; foreach(@sorted_keys){ if ($rows<5){ print "<tr height=\"8\"><td><font face=\"Verdana\" size=\"1\">" . $_ + . "</font></td><td height=\"22\"><font face=\"Verdana\" size=\"1\">" + . $seen_hash{$_} . "</font></td></tr>\n"; } $rows++; } print "</table>"; Data -------- search|ip address|time stamp search|ip address|time stamp search2|ip address|time stamp
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-03-28 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found