in reply to count sort & output II
There are indeed some caveats mabout your code. You'll for example get some uninitialized warnings, because $hour and $minute may be undef. param() returns undef for parameters that weren't submitted at all.
Next, this is not a matter of effectivity, but style, use CGI to generate your HTML (and generate HTML, you don't yet). After al, you're loading the module so use it.
"$data" is equivalent to $data, for $data is a plain string.
In terms of speed: use defined() and exists():
# why evaluate true/false? #while (my $line = <FH>) { # defined() is enough: while(defined( my $line = <FH> ) ){ #--- # why retrieve value und evaluate true/false? if (!$referers{$2}) { # when exists() can do thie way faster if( not exists $referers{$2} ){
Next, you cannot do things via CGI you're used from the commandline. STDIN contains POST-Submitted form data, it is not terminal input in CGI context.
You'll need to have another request in order to have a next page. For CGI this means all the work has to begin again.
You see: the whole thing becomes more difficult. To create an acceptably fast output, store the data differently: Save things sorted by Referer and update that database (needn't be a real database but would be most efficient) whenever the actual logfile is updated.
--
|
|---|