Perlfect Solutions

[Perlfect-search] what is the best way to log multiple search box activity?

Rusty Wilson
Fri, 23 Aug 2002 11:15:00 -0700 (PDT)
--- Daniel Naber <> wrote:
> You'll have to modify the log_query() function in so that it 
> writes one more column that contains the "name" of the box (hidden 
> parameter).

Assuming I put the following in the search form:
<input type="hidden" name="searchbox" value="oem">

Would this be the correct modification so that oem appears in the log file?

sub log_query {
  return if( ! $LOG );

  my $elapsed_time = sprintf("%.2f", Time::HiRes::tv_interval($start_time)) if(
$start_time );
  my @line = ();
  my $addr = $ENV{'REMOTE_HOST'} || $ENV{'REMOTE_ADDR'};
  push(@line, $addr || '-',
              $query->param('q') || '-',
              scalar(keys %answer),
              $query->param('p') || 1,
              $elapsed_time || '-');
  use Fcntl ':flock';        # import LOCK_* constants
  open(LOG, ">>$LOGFILE") or die "Cannot open logfile '$LOGFILE' for writing:
  flock(LOG, LOCK_EX);
  seek(LOG, 0, 2);
  print LOG join(';', @line).";\n";
  flock(LOG, LOCK_UN);

The Website your boss doesn�t want you to know about! ('s FREE!)

Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes