X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXLogPrint.pm;h=92deee427026cf1e574b3a66c5d479a88131304f;hb=2fe3813e70786483d2d928f8fa44eb9ff9cb76ca;hp=9bb51f20a579a2e34ecf6220e5690ba7cd9e420a;hpb=dd902a3e23aeb207178d9960f17b757262842ed6;p=spider.git diff --git a/perl/DXLogPrint.pm b/perl/DXLogPrint.pm index 9bb51f20..92deee42 100644 --- a/perl/DXLogPrint.pm +++ b/perl/DXLogPrint.pm @@ -18,9 +18,12 @@ use DXLog; use Julian; -our $readback = `which tac`; +our $readback = 1; +if ($readback) { + $readback = `which tac`; +} chomp $readback; -undef $readback; # yet another reason not to use the cloud! +#undef $readback; # yet another reason not to use the cloud! use strict; @@ -33,11 +36,11 @@ $maxmonths = 36; # # This command outputs a list of n lines starting from time t with $pattern tags # -sub print +sub search { my $fcb = $DXLog::log; - my $from = shift || 0; - my $to = shift || 10; + my $from = shift // 0; + my $to = shift // 10; my $jdate = $fcb->unixtoj(shift); my $pattern = shift; my $who = shift; @@ -50,17 +53,19 @@ sub print $who = uc $who if defined $who; + dbg("from: $from to: $to pattern: $pattern hint: $hint") if isdbg('search'); + if ($pattern) { - $hint = q{m{\Q$pattern\E}i}; + $hint = qq{m{\Q$pattern\E}i}; } else { $hint = q{!m{\^(?:ann|rcmd|talk|chat)\^}}; } if ($who) { $hint .= ' && ' if $hint; - $hint .= q{m{\Q$who\E}oi}; + $hint .= q{m{\Q$who\E}i}; } $hint = "next unless $hint" if $hint; - $hint .= "; next unless m{^\\d+\\^$pattern\\^}" if $pattern; + $hint .= "; next unless m{^\\d+\\^$pattern\\^}i" if $pattern; $hint ||= ""; $eval = qq(while (<\$fh>) { @@ -109,10 +114,20 @@ sub print return "show/$name: ${s}not found"; } - for (reverse @in) { - my @line = split /\^/ ; - push @out, print_item(\@line); - + for (sort {$a cmp $b } @in) { + push @out, [ split /\^/ ] + } + + return @out; +} + +sub print +{ + my @out; + + my @in = search(@_); + for (@in) { + push @out, print_item($_); } return @out; }