Medium sized Internalization made by flattener against megalog-2018-06-29
[andk-cpan-tools.git] / bin / accessloggrep
blob9cc02b471b117b1918a8362dc1481d3dc0162c6a
1 #!/usr/bin/perl -nl
3 # ad hoc
5 use strict;
6 my %F; our @F; our @G; our $OPS;
7 BEGIN {
8 @F = qw(IP D1 USER DD MM YYYY hh mm ss REQ OK BYTE PROC PORT SECS REF UA);
9 $OPS = qr/(==|>)/;
10 while (@ARGV && $ARGV[0] =~ /\s$OPS\s/) {
11 push @G, shift @ARGV;
14 @F{@F} = m{
15 ^(\S+)\s+ #IP
16 (\S+)\s+ #D1
17 (\S+)\s+ #USER
18 \[(\d+) /
19 (\w+) /
20 (\d+) :
21 (\d+) :
22 (\d+) :
23 (\d+)
24 [^\]]+\]\s+ #DD MM YYYY hh mm ss
25 (\".*?\")\s+ #REQ
26 (\d+)\s+ #OK
27 (\S+)\s+ #BYTE may be -
28 (\d+)\s+ #PROC
29 (\d+)\s+ #PORT
30 (\d+)\s+ #SECS
31 (\".*?\")\s+ #REF we had a quote and a blank in it
32 (\"[^\"]*\") #UA
33 }x;
34 die $_ unless $F{D1};
35 my $print = 0;
36 for my $arg (@G){
37 my($field,$compare,$value) = split " ", $arg, 3;
38 die "illegal" unless $compare =~ /^$OPS$/;
39 if (0) {
40 } elsif (
41 $compare eq "==" && $F{$field} == $value
43 $compare eq ">" && $F{$field} > $value
44 ) {
45 $print++
48 print if $print;