X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXLogPrint.pm;h=6d37cb415d16ddfba84d481aa69055e881f653d2;hb=86316dcf45d7cbdcd8e3f512be655242ab1701ff;hp=185912cda4948abefe7d3408da3d371651921417;hpb=c20a2c1e01d707d6c3fa25067df93d491aba8fff;p=spider.git diff --git a/perl/DXLogPrint.pm b/perl/DXLogPrint.pm index 185912cd..6d37cb41 100644 --- a/perl/DXLogPrint.pm +++ b/perl/DXLogPrint.pm @@ -35,14 +35,33 @@ sub print my @out = (); my $eval; my $count; + my $hint = ""; - $search = '1' unless $pattern || $who; - $search = "\$ref->[1] =~ /$pattern/i" if $pattern; - $search .= ' && ' if $pattern && $who; - $search .= "(\$ref->[2] =~ /$who/i || \$ref->[3] =~ /$who/i)" if $who; + if ($pattern) { + $search = "\$ref->[1] =~ m{^$pattern}i"; + $hint = "m{$pattern}i"; + } + if ($who) { + if ($search) { + $search .= ' && '; + $hint .= ' && '; + } + $search .= "(\$ref->[2] =~ m{$who}i || \$ref->[3] =~ m{$who}i)"; + $hint .= 'm{$who}i'; + } + $hint = "next unless $hint" if $hint; + $search = "1" unless $search; + $eval = qq( + \@in = (); + while (<\$fh>) { + $hint; + chomp; + \$ref = [ split '\\^' ]; + push \@\$ref, "" unless \@\$ref >= 4; + push \@in, \$ref; + } my \$c; - my \$ref; for (\$c = \$#in; \$c >= 0; \$c--) { \$ref = \$in[\$c]; if ($search) { @@ -60,13 +79,6 @@ sub print for ($count = 0; $count < $to; ) { my $ref; if ($fh) { - @in = (); - while (<$fh>) { - chomp; - $ref = [ split '\^' ]; - push @{$ref}, "" unless @{$ref} >= 4; - push @in, $ref; - } eval $eval; # do the search on this file last if $count >= $to; # stop after n return ("Log search error", $@) if $@;