X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXLogPrint.pm;h=9c5633e1fbf2d3bb085d8eeec62c4bf267ebd3b5;hb=68a71e7d4cb7bdb19162413094333fb8a0b09bfa;hp=fff39d1256894e6a1765249f0ac157d85fa65b0a;hpb=099c6b4a10d9f1e7471b0c94273cd992b5814cdc;p=spider.git diff --git a/perl/DXLogPrint.pm b/perl/DXLogPrint.pm index fff39d12..9c5633e1 100644 --- a/perl/DXLogPrint.pm +++ b/perl/DXLogPrint.pm @@ -30,13 +30,17 @@ sub print my $to = shift; my @date = $self->unixtoj(shift); my $pattern = shift; + my $who = uc shift; my $search; my @in; my @out; my $eval; my $count; - $search = $pattern ? "\$ref->[1] =~ /$pattern/" : '1' ; + $search = '1' unless $pattern || $who; + $search = "\$ref->[1] =~ /$pattern/" if $pattern; + $search .= ' && ' if $pattern && $who; + $search .= "(\$ref->[2] =~ /$who/ || \$ref->[3] =~ /$who/)" if $who; $eval = qq( my \$c; my \$ref; @@ -46,7 +50,7 @@ sub print \$count++; next if \$count < $from; push \@out, print_item(\$ref); - last LOOP if \$count >= \$to; # stop after n + last if \$count >= \$to; # stop after n } } ); @@ -54,8 +58,7 @@ sub print $self->close; # close any open files my $fh = $self->open(@date); -LOOP: - while ($count < $to) { + for ($count = 0; $count < $to; ) { my @spots = (); if ($fh) { while (<$fh>) { @@ -63,13 +66,14 @@ LOOP: push @in, [ split '\^' ]; } eval $eval; # do the search on this file - return ("Spot search error", $@) if $@; + last if $count >= $to; # stop after n + return ("Log search error", $@) if $@; } $fh = $self->openprev(); # get the next file last if !$fh; } - - return @out; + + return @out if defined @out; } # @@ -98,7 +102,7 @@ sub print_item } elsif ($ref[1] eq 'talk') { $s = "$ref[3] -> $ref[2] ($ref[4]) $ref[5]"; } elsif ($ref[1] eq 'ann') { - $s = "$ref[2] -> $ref[3] $ref[4]"; + $s = "$ref[3] -> $ref[2] $ref[4]"; } else { $s = "$ref[2]"; }