foreach my $file (readdir(DIR)) {
next unless ($file =~ m/^mail\.log/);
open(IN, "<$file") or die "Couldn't open $file: $!";
my $count;
foreach my $line (<IN>) {
$count++;
if ($line =~ m/$pattern/) {
print REPORT "File\t$file contains\t$1 on line\t$count!\n"
+;
print LINES $line;
}
}
close(IN);
}