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;
\$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
}
}
);
$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>) {
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;
}
#
} 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]";
}