Hello Everyone:

I'm trying determine the best way to check if a file name is contained 
within a couple of larger files. I can do a grep from the command line 
but, what's the fun of that!?  Plus there's  about a hundred files which 
would be tedious.

Here's my coding attempt:

$dirname = "/var/tmp/allfiles";
@filenames = qw(file1 file2 file3 file4 file5);
opendir(DIR, $dirname) or die "Can't open $dirname: $!";
     while (defined(@files = readdir(DIR)))
     {
        foreach my $searchfile ( @files )
         {
                next if $searchfile =~ /^\.\.?$/;
                         open(FH, "<$dirname/$searchfile") or die;
                
                        while(<FH>)
                        {
                           foreach my $foundfile ( @filenames )
                           {
                                print "$foundfile\n" if -T "$dirname/$searchfile";
                           }
                        }
                close(FH);
        }
    }
closedir(DIR);


So if I have only five files to check against a hundred I'm lost. Please 
help!

George Sala

Reply via email to