#!/usr/local/bin/perl -w use strict; use CGI qw(:standard :escape); param('athensid') && &search_stats(param('athensid')); &search_form; exit; ######## sub search_stats { my $athensid=shift; return unless $athensid; print header,start_html(-title=>"Find Ovid user from Athens id"); my @stats=("/online/stats/ka24iwlaa/master.log","/online/stats/ka24iwlaa/old/master.log.archive"); my %users; foreach my $file (@stats) { open(F,"<$file")||die "Can't read $file"; while() { if (/^USER (\w+) TIME \S+ \S+ LEN \S+ SESSIONTYPE WEB ORIGINADDRESS \S+ ACCTCOMMENT $athensid:\w+$/) { print $1; exit; } } close(F); } print "no $athensid in the ka24 statistics files.\n"; exit; } ############ sub search_form { print header,start_html, start_html(-title=>"Find Ovid user from Athens id"); print start_form(-action=>url()), "athens id: ", textfield(-name=>'athensid'); print submit; }