Greetings: All,
I would like to know how can I determine if my file name is in another
file? Here's my example:
Using files in my mail queue, I am able to read in and check for a
pattern. I have the original files file name, let's call it QUEUE.XZZ.
Now, I want to check if 'QUEUE.XYZ' is listed in one of the control
files in another <DIR> If a match is found skip and goto the next one.
If no match then display on the screen.
filename: QUEUE.XYZ
controlfile: control-file.200010712-1 thru -10
deferred: <dir1> <dir2> d<dir3> each with one or more files to check
for 'filename'
---code snip------
# Local directories to search for files
#
local $queue_dir = "/var/tmp/que/messages";
local $control_dir = "/var/tmp/que/control";
local $deferred_dir = "/var/tmp/que/deferred";
my_string = "Subject: Mail Errors";
# Read in the Queue file for processing
#
opendir(THISDIR, "${queue_dir}");
@files = grep(! /^\./, readdir(THISDIR));
closedir(THISDIR);
#Read in the Deferred files to search for Queue file names
# This area has several other sub directories
#
opendir(DEFERREDdir, "$deferred_dir") or die ("Can't open
$deferred_dir:$!\n");
@deferredFiles = grep(! /^\./, readdir(DEFERREDdir));
close(DEFERREDdir);
#Read in the Control files to search for Queue file names
# This area has several other sub directories
#
opendir(CONTROLdir, "$control_dir") or die ("Can't open
$control_dir:$!\n");
@controlFiles = grep(! /^\./, readdri(CONTROLdir));
closedir(CONTROLdir);
foreach $file (@files) {
$seen = 0;
$file_count++;
open(FH, "<$file");
while(<FH>) {
if ($_ =~ /^$my_string/) {
# Problem area not working as desired ---
foreach $controlfile ( @controlFiles ) {
open(CONTROL,"<$control_dir/$controlfile") or die
"Can't open $control_dir/$controlfile:$!\n";
while(<CONTROL>) {
$found_match = grep(/$file/, "$controlfile");
if ($found_match) {
print "Match found in $controlfile with $file\n";
last;
}
}
close(CONTROL);
}
close(FH);
$seen = 1;
$total_seen++;
last;
}
}
}
print "Total queue matched: $total_seen processed, $file_count\n";
-----------End of snip------------------
Any assistance, advice is appreciated,
BK Freeman