Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w $apache_log="/(.*)\s+-\s+-\s+\[(\d+)\/(\w+)\/(\d+):(\d+):(\d+)/"; # Hmm I know there is a better way to parse this $iis_log="/(\d+):(\d+):(\d+)\s+(\d+\.\d+\.\d+\.\d+)\s/"; $document="/report.html\?/"; $document2="/secret.html\?/"; # open the log file - the log file we want to check out open(LOG, "<$ARGV[0]") || die("Could not open $ARGV[0] : $!"); # open our Report file - the file we will write out report to open(REPORT, ">$ARGV[1]") || die("Could not open $ARGV[1] : $!"); while(<LOG>){ if($document){ ($ip, $day, $month, $year, $hr, $min) = $_ = $apache_log; # if I was + using IIS I would set this to $iis_log, is there a better way? $totaldoc++; print REPORT "Access on doc1 from: $ip on $month $day at $hr:$min\n" +; } elsif($document2){ $totaldoc2++; print REPORT "Access on doc2 from: $ip on $month $day at $hr:$min\n" +; } } print REPORT "Total doc1: $totaldoc\n"; print REPORT "Total doc2: $totaldoc2\n"; close(LOG); close(REPORT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: question about regex and using a scalar variable to store/call it
by suaveant (Parson) on Sep 20, 2001 at 18:10 UTC | |
|
Re: question about regex and using a scalar variable to store/call it
by tommyw (Hermit) on Sep 20, 2001 at 18:07 UTC | |
|
Re: question about regex and using a scalar variable to store/call it
by Rhose (Priest) on Sep 20, 2001 at 18:27 UTC |