Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: count sort & output II

by fruiture (Curate)
on Dec 19, 2002 at 17:35 UTC ( [id://221184]=note: print w/replies, xml ) Need Help??

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.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://221184]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-06-14 03:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.